@@ -26,14 +26,14 @@ def test_aws_secret_key(self):
2626
2727 def test_jwt_token (self ):
2828 """Test JWT token redaction."""
29- text = "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
29+ text = "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" # nosemgrep: generic.secrets.security.detected-jwt-token # gitleaks:allow
3030 result = scrub_credentials (text )
3131 assert "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9" not in result
3232 assert "[REDACTED-JWT-TOKEN]" in result
3333
3434 def test_github_token (self ):
3535 """Test GitHub personal access token redaction."""
36- text = "GITHUB_TOKEN=ghp_1234567890abcdefghijklmnopqrstuv"
36+ text = "GITHUB_TOKEN=ghp_1234567890abcdefghijklmnopqrstuv" # gitleaks:allow
3737 result = scrub_credentials (text )
3838 assert "ghp_1234567890abcdefghijklmnopqrstuv" not in result
3939 assert "[REDACTED-GITHUB-TOKEN]" in result
@@ -60,7 +60,7 @@ def test_private_key(self):
6060
6161 def test_api_key_hex (self ):
6262 """Test generic API key redaction (hex format)."""
63- text = "api_key=a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4"
63+ text = "api_key=a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4" # nosemgrep: generic.secrets.security.detected-generic-api-key # gitleaks:allow
6464 result = scrub_credentials (text )
6565 assert "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4" not in result
6666 assert "[REDACTED-API-KEY]" in result
@@ -70,7 +70,7 @@ def test_multiple_credentials(self):
7070 text = """
7171 AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
7272 AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
73- TOKEN=ghp_1234567890abcdefghijklmnopqrstuv
73+ TOKEN=ghp_1234567890abcdefghijklmnopqrstuv # gitleaks:allow
7474 """
7575 result = scrub_credentials (text )
7676 assert "AKIAIOSFODNN7EXAMPLE" not in result
@@ -104,7 +104,7 @@ class TestScrubDictValues:
104104 def test_scrub_all_strings (self ):
105105 """Test scrubbing all string values in a dict."""
106106 data = {
107- "token" : "ghp_1234567890abcdefghijklmnopqrstuv" ,
107+ "token" : "ghp_1234567890abcdefghijklmnopqrstuv" , # gitleaks:allow
108108 "count" : 42 ,
109109 "message" : "Hello world" ,
110110 }
@@ -116,8 +116,8 @@ def test_scrub_all_strings(self):
116116 def test_scrub_specific_keys (self ):
117117 """Test scrubbing only targeted keys."""
118118 data = {
119- "token" : "ghp_1234567890abcdefghijklmnopqrstuv" ,
120- "message" : "ghp_1234567890abcdefghijklmnopqrstuv" ,
119+ "token" : "ghp_1234567890abcdefghijklmnopqrstuv" , # gitleaks:allow
120+ "message" : "ghp_1234567890abcdefghijklmnopqrstuv" , # gitleaks:allow
121121 }
122122 result = scrub_dict_values (data , keys_to_scrub = {"token" })
123123 assert "ghp_1234567890abcdefghijklmnopqrstuv" not in result ["token" ]
0 commit comments