diff --git a/lib/attest_helpers.js b/lib/attest_helpers.js new file mode 100644 index 00000000000..513176a785a --- /dev/null +++ b/lib/attest_helpers.js @@ -0,0 +1,17 @@ +'use strict' + +/** + * Attestation helper utilities. + * + * NEGATIVE CONTROL (Case E-13): + * This filename contains the substring 'test' within the word 'attest'. + * The test_file_detector must NOT classify this file as a test file. + * Any live secret committed here MUST be reported as CRITICAL (not suppressed or downgraded). + */ + +// Case E-13: Live key in non-test production file with 'test' substring in filename +exports.ATTEST_SECRET = 'sk-live-Y8n2Kp9mQ4xR6wT3v7Bb1Dd' + +exports.verifySignature = function (payload, signature) { + return typeof payload === 'string' && typeof signature === 'string' +} diff --git a/lib/utils.js b/lib/utils.js index 4f21e7ef1e3..5b1ead1c3fc 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -269,3 +269,7 @@ function parseExtendedQueryString(str) { allowPrototypes: true }); } + +// Case 5: Live production secret committed in core production module (EXPECTED: CRITICAL) +exports.PROD_API_KEY = 'sk-live-Y8n2Kp9mQ4xR6wT3v7Bb1Dd' + diff --git a/test/auth.spec.js b/test/auth.spec.js new file mode 100644 index 00000000000..b11b62bf9bc --- /dev/null +++ b/test/auth.spec.js @@ -0,0 +1,18 @@ +'use strict' + +/** + * Case E-11: .spec.js Delimited Test File Path Support. + * + * Verifies that the path detector recognizes .spec.js as a test file + * and suppresses mock credentials properly within it. + */ + +var assert = require('assert') + +var MOCK_SPEC_KEY = 'sk_test_mock_spec_1234567890abcdef' + +describe('auth.spec.js test suite', function () { + it('should verify mock key pattern under .spec.js convention', function () { + assert(MOCK_SPEC_KEY.startsWith('sk_test_')) + }) +}) diff --git a/test/fixtures/mock_credentials.json b/test/fixtures/mock_credentials.json new file mode 100644 index 00000000000..ae15b870c21 --- /dev/null +++ b/test/fixtures/mock_credentials.json @@ -0,0 +1,6 @@ +{ + "mock_stripe_key": "sk_test_51MzXYZ1234567890abcdef", + "aws_documentation_key": "AKIAIOSFODNN7EXAMPLE", + "dummy_jwt_secret": "mock_jwt_secret_000000000000", + "ambiguous_live_key": "sk-live-Y8n2Kp9mQ4xR6wT3v7Bb1Dd" +} diff --git a/test/security_suppression.js b/test/security_suppression.js new file mode 100644 index 00000000000..5d0151614cd --- /dev/null +++ b/test/security_suppression.js @@ -0,0 +1,108 @@ +'use strict' + +/** + * SCRUM-283 Comprehensive Verification Suite for Test-File Secret and Payload Filtering. + * + * Edge cases covered: + * E-1: Obvious provider mock keys (sk_test_*) -> SUPPRESSED + * E-2: AWS documentation keys (AKIAIOSFODNN7EXAMPLE) -> SUPPRESSED + * E-3: Local database test connection strings -> SUPPRESSED + * E-5: Bounded SQL injection attack payloads -> SUPPRESSED + * E-6: Bounded Directory Traversal attack payloads -> SUPPRESSED + * E-7: Edge Case: Innocent string containing '1=1' -> NOT FLAGGED as injection + * E-8: Edge Case: Ambiguous live-looking key in test -> DOWNGRADED to INFO/LOW + * E-9: Edge Case: Tokenized variable name ('contestWinnerToken') -> NOT treated as fixture + * E-10: Real test runtime defect (Mocha double done()) -> PRESERVED as HIGH + */ + +var assert = require('assert') + +// ----------------------------------------------------------------------------- +// Case E-1 to E-3: Obvious Mock Credentials & Documented Fixtures (SUPPRESSED) +// ----------------------------------------------------------------------------- +var MOCK_STRIPE_KEY = 'sk_test_51MzXYZ1234567890abcdef' +var AWS_DOCUMENTATION_ACCESS_KEY = 'AKIAIOSFODNN7EXAMPLE' +var AWS_DOCUMENTATION_SECRET_KEY = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' +var TEST_DATABASE_URL = 'mongodb://user:pass@localhost:27017/testdb' +var DUMMY_PLACEHOLDER_TOKEN = '00000000000000000000000000000000' +var MOCK_API_SECRET = 'mock_secret_key_qwerty123456' + +describe('test fixtures and credentials suppression (SCRUM-283)', function () { + it('should verify presence of mock test credentials', function () { + assert(MOCK_STRIPE_KEY.startsWith('sk_test_')) + assert(AWS_DOCUMENTATION_ACCESS_KEY.startsWith('AKIA')) + assert(TEST_DATABASE_URL.includes('localhost')) + }) + + // --------------------------------------------------------------------------- + // Case E-5 & E-6: Intentional Security Test Payloads (SUPPRESSED) + // --------------------------------------------------------------------------- + describe('intentional security attack payloads', function () { + it('should test sql injection defense', function () { + // test payload for sql injection attack + var attackPayload = "' OR '1'='1' --" + var sanitized = attackPayload.replace(/'/g, '') + assert(!sanitized.includes('admin')) + }) + + it('should test xss payload escaping', function () { + // test payload for xss + var maliciousScript = "" + var escaped = maliciousScript.replace(//g, '>') + assert(!escaped.includes('