From c6fe3998f800649a8879db65a2eac93e8f42cbed Mon Sep 17 00:00:00 2001 From: 206784430_nbcuni <176340413+206784430_nbcuni@users.noreply.github.com> Date: Thu, 10 Jul 2025 15:48:51 -0400 Subject: [PATCH 1/2] Add additional tests --- .../SCTE35ParserTests/SCTE35ParserTests.swift | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Tests/SCTE35ParserTests/SCTE35ParserTests.swift b/Tests/SCTE35ParserTests/SCTE35ParserTests.swift index 3c9e7b5..c2c55a6 100644 --- a/Tests/SCTE35ParserTests/SCTE35ParserTests.swift +++ b/Tests/SCTE35ParserTests/SCTE35ParserTests.swift @@ -1402,4 +1402,51 @@ final class SCTE35ParserTests: XCTestCase { ) try XCTAssertEqual(expectedSpliceInfoSection, SpliceInfoSection(base64String)) } + + // MARK: - Input Validation + + /// Test: ISAN/EIDR UPID with non-hex character to target force-unwrap + func test_invalidHexInISANShouldThrow() { + let badISANHex = "FC302000000000000000FFF00506FE00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z" + XCTAssertThrowsError(try SpliceInfoSection(hexString: badISANHex), "Malformed ISAN with non-hex char should throw") + } + + /// Test: Fuzz with random data to ensure parser never crashes + func test_randomNoiseInput_shouldNotCrash() { + for _ in 0..<100 { + let randomData = Data((0.. Date: Fri, 11 Jul 2025 10:58:25 -0400 Subject: [PATCH 2/2] Add comment for clarity --- Tests/SCTE35ParserTests/SCTE35ParserTests.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/SCTE35ParserTests/SCTE35ParserTests.swift b/Tests/SCTE35ParserTests/SCTE35ParserTests.swift index c2c55a6..a3d39ef 100644 --- a/Tests/SCTE35ParserTests/SCTE35ParserTests.swift +++ b/Tests/SCTE35ParserTests/SCTE35ParserTests.swift @@ -1412,6 +1412,8 @@ final class SCTE35ParserTests: XCTestCase { } /// Test: Fuzz with random data to ensure parser never crashes + /// The main purpose of this test is to ensure that parsing random base64 input does not crash the parser or the test runner. + /// The XCTAssertNoThrow assertion is used here for clarity, but the key goal is to validate parser stability, not the assertion itself. func test_randomNoiseInput_shouldNotCrash() { for _ in 0..<100 { let randomData = Data((0..