Skip to content

Commit 3098639

Browse files
committed
Remove unnecessary backwards compat logic
Signed-off-by: lelia <lelia@socket.dev>
1 parent 9ded636 commit 3098639

File tree

2 files changed

+8
-32
lines changed

2 files changed

+8
-32
lines changed

socketsecurity/config.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ class CliConfig:
8181
enable_json: bool = False
8282
enable_sarif: bool = False
8383
sarif_file: Optional[str] = None
84-
sarif_reachable_only: bool = False
8584
sarif_scope: str = "diff"
8685
sarif_grouping: str = "instance"
8786
sarif_reachability: str = "all"
@@ -168,13 +167,6 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
168167
if args.sarif_file:
169168
args.enable_sarif = True
170169

171-
# Backward-compatible shim: --sarif-reachable-only => --sarif-reachability reachable
172-
if args.sarif_reachable_only:
173-
if args.sarif_reachability not in ("all", "reachable"):
174-
logging.error("--sarif-reachable-only conflicts with --sarif-reachability")
175-
exit(1)
176-
args.sarif_reachability = "reachable"
177-
178170
# Strip quotes from commit message if present
179171
commit_message = args.commit_message
180172
if commit_message and commit_message.startswith('"') and commit_message.endswith('"'):
@@ -199,7 +191,6 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
199191
'enable_json': args.enable_json,
200192
'enable_sarif': args.enable_sarif,
201193
'sarif_file': args.sarif_file,
202-
'sarif_reachable_only': args.sarif_reachable_only,
203194
'sarif_scope': args.sarif_scope,
204195
'sarif_grouping': args.sarif_grouping,
205196
'sarif_reachability': args.sarif_reachability,
@@ -289,10 +280,6 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
289280
logging.error("--workspace-name requires --sub-path to be specified")
290281
exit(1)
291282

292-
# Validate that sarif_reachable_only requires reach
293-
if args.sarif_reachable_only and not args.reach:
294-
logging.error("--sarif-reachable-only requires --reach to be specified")
295-
exit(1)
296283
if args.sarif_scope == "full" and not args.reach:
297284
logging.error("--sarif-scope full requires --reach to be specified")
298285
exit(1)
@@ -586,12 +573,6 @@ def create_argument_parser() -> argparse.ArgumentParser:
586573
default=None,
587574
help="Output file path for SARIF report (implies --enable-sarif)"
588575
)
589-
output_group.add_argument(
590-
"--sarif-reachable-only",
591-
dest="sarif_reachable_only",
592-
action="store_true",
593-
help="Filter SARIF output to only include reachable findings (requires --reach)"
594-
)
595576
output_group.add_argument(
596577
"--sarif-scope",
597578
dest="sarif_scope",

tests/unit/test_config.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,11 @@ class TestCliConfigValidation:
7474

7575
BASE_ARGS = ["--api-token", "test-token", "--repo", "test-repo"]
7676

77-
def test_sarif_reachable_only_without_reach_exits(self):
78-
"""--sarif-reachable-only without --reach should exit with code 1"""
77+
def test_sarif_reachable_only_is_not_supported(self):
78+
"""Legacy --sarif-reachable-only is removed; argparse should reject it."""
7979
with pytest.raises(SystemExit) as exc_info:
80-
CliConfig.from_args(self.BASE_ARGS + ["--sarif-reachable-only"])
81-
assert exc_info.value.code == 1
82-
83-
def test_sarif_reachable_only_with_reach_succeeds(self):
84-
"""--sarif-reachable-only with --reach should not raise"""
85-
config = CliConfig.from_args(self.BASE_ARGS + ["--sarif-reachable-only", "--reach"])
86-
assert config.sarif_reachable_only is True
87-
assert config.reach is True
80+
CliConfig.from_args(self.BASE_ARGS + ["--sarif-reachable-only", "--reach"])
81+
assert exc_info.value.code == 2
8882

8983
def test_sarif_file_implies_enable_sarif(self):
9084
"""--sarif-file should automatically set enable_sarif=True"""
@@ -121,8 +115,8 @@ def test_sarif_grouping_alert_requires_full_scope(self):
121115
CliConfig.from_args(self.BASE_ARGS + ["--reach", "--sarif-grouping", "alert"])
122116
assert exc_info.value.code == 1
123117

124-
def test_legacy_sarif_reachable_only_maps_to_reachability(self):
125-
config = CliConfig.from_args(self.BASE_ARGS + ["--reach", "--sarif-reachable-only"])
118+
def test_sarif_reachability_reachable_with_reach_succeeds(self):
119+
config = CliConfig.from_args(self.BASE_ARGS + ["--reach", "--sarif-reachability", "reachable"])
126120
assert config.sarif_reachability == "reachable"
127121

128122
def test_config_file_toml_sets_defaults(self, tmp_path):
@@ -160,10 +154,11 @@ def test_cli_flag_overrides_config_file(self, tmp_path):
160154
def test_config_file_json_sets_defaults(self, tmp_path):
161155
config_path = tmp_path / "socketcli.json"
162156
config_path.write_text(
163-
"{\"socketcli\": {\"reach\": true, \"sarif_scope\": \"full\", \"sarif_grouping\": \"alert\"}}",
157+
"{\"socketcli\": {\"reach\": true, \"sarif_scope\": \"full\", \"sarif_grouping\": \"alert\", \"sarif_reachability\": \"reachable\"}}",
164158
encoding="utf-8",
165159
)
166160
config = CliConfig.from_args(self.BASE_ARGS + ["--config", str(config_path)])
167161
assert config.reach is True
168162
assert config.sarif_scope == "full"
169163
assert config.sarif_grouping == "alert"
164+
assert config.sarif_reachability == "reachable"

0 commit comments

Comments
 (0)