Skip to content

Commit 66a825c

Browse files
committed
Keep the ignore authorization policy visible in debug output
1 parent 45ede41 commit 66a825c

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
- Configuration debug output masks credential fields, including nested plugin
2424
settings, and integration URL paths. Slack configuration environment contents
2525
are reported only as set or unset.
26+
- The ignore-command authorization policy remains visible in configuration
27+
debug output so comment-handling decisions can be diagnosed.
2628
- Alert timestamps retain their leading and trailing characters when the
2729
optional timezone suffix is removed.
2830
- Slack, Teams, Jira, webhook, and GitLab commit-status requests use a 30-second

‎socketsecurity/redaction.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
def is_sensitive_name(name: str) -> bool:
2424
"""Whether a field name looks like it holds a credential."""
2525
lowered = name.lower()
26+
# The ignore-command authorization policy is public configuration.
27+
if lowered == "ignore_authorization":
28+
return False
2629
return any(marker in lowered for marker in _SENSITIVE_NAME_MARKERS)
2730

2831

‎tests/unit/test_redaction.py‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,36 @@ def _clear_token_env(monkeypatch):
3535

3636
@pytest.mark.parametrize(
3737
"name",
38-
["api_token", "API_TOKEN", "github_token", "slack_webhook", "client_secret", "password", "auth_header", "api_key"],
38+
[
39+
"api_token",
40+
"API_TOKEN",
41+
"github_token",
42+
"slack_webhook",
43+
"client_secret",
44+
"password",
45+
"auth_header",
46+
"api_key",
47+
"authorization",
48+
"ignore_authorization_token",
49+
],
3950
)
4051
def test_credential_field_names_are_recognized(name):
4152
assert is_sensitive_name(name)
4253

4354

44-
@pytest.mark.parametrize("name", ["repo", "branch", "commit_sha", "target_path", "scm", "enable_debug"])
55+
@pytest.mark.parametrize(
56+
"name",
57+
[
58+
"repo",
59+
"branch",
60+
"commit_sha",
61+
"target_path",
62+
"scm",
63+
"enable_debug",
64+
"ignore_authorization",
65+
"IGNORE_AUTHORIZATION",
66+
],
67+
)
4568
def test_ordinary_field_names_are_not_recognized(name):
4669
assert not is_sensitive_name(name)
4770

@@ -107,6 +130,15 @@ def test_config_to_redacted_dict_masks_the_api_token():
107130
assert TOKEN not in str(config.to_redacted_dict())
108131

109132

133+
@pytest.mark.parametrize("policy", ["enforce", "strict", "off"])
134+
def test_ignore_authorization_policy_remains_visible_in_config_debug_output(policy):
135+
config = CliConfig.from_args(["--api-token", TOKEN, "--repo", "widgets", "--ignore-authorization", policy])
136+
view = config.to_redacted_dict()
137+
assert view["ignore_authorization"] == policy
138+
assert view["api_token"] == REDACTED
139+
assert redact_mapping({"authorization": f"Bearer {TOKEN}"})["authorization"] == REDACTED
140+
141+
110142
def test_every_credential_field_on_cliconfig_is_redacted():
111143
"""All credential-named config fields must be masked by the logging view."""
112144
config = CliConfig.from_args(["--api-token", TOKEN, "--repo", "widgets"])

0 commit comments

Comments
 (0)