Skip to content

Commit 0601faa

Browse files
committed
refactor: enhance security checks in publish command and update tests
Updated the security check implementation in the publish command to use 'ruff' with an '--exit-zero' flag, changing the output handling to display warnings instead of errors. Adjusted the test cases to reflect these changes, ensuring that security warnings are correctly asserted. This improves the clarity of security feedback during the publishing process.
1 parent e031120 commit 0601faa

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

comfy_cli/command/custom_nodes/command.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -709,14 +709,16 @@ def publish(
709709
# Run security checks first
710710
typer.echo("Running security checks...")
711711
try:
712-
# Run ruff check with security rules
713-
cmd = ["ruff", "check", ".", "--select", "S102,S307"]
712+
# Run ruff check with security rules and --exit-zero to only warn
713+
cmd = ["ruff", "check", ".", "--select", "S102,S307", "--exit-zero"]
714714
result = subprocess.run(cmd, capture_output=True, text=True)
715715

716-
if result.returncode != 0:
717-
print("[red]Security issues found:[/red]")
716+
if result.stdout: # Changed from checking returncode to checking if there's output
717+
print("[yellow]Security warnings found:[/yellow]") # Changed from red to yellow to indicate warning
718718
print(result.stdout)
719-
raise typer.Exit(code=1)
719+
print("[bold yellow]We will soon disable exec and eval, so this will be an error soon.[/bold yellow]")
720+
# TODO: re-enable exit when we disable exec and eval
721+
# raise typer.Exit(code=1)
720722

721723
except FileNotFoundError:
722724
print("[red]Ruff is not installed. Please install it with 'pip install ruff'[/red]")

tests/comfy_cli/command/nodes/test_publish.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ def test_publish_fails_on_security_violations():
1313
mock_result.returncode = 1
1414
mock_result.stdout = "S102 Use of exec() detected"
1515

16-
with patch("subprocess.run", return_value=mock_result):
16+
with (
17+
patch("subprocess.run", return_value=mock_result),
18+
patch("typer.prompt", return_value="test-token"),
19+
):
1720
result = runner.invoke(app, ["publish"])
1821

19-
assert result.exit_code == 1
20-
assert "Security issues found" in result.stdout
22+
# TODO: re-enable exit when we disable exec and eval
23+
# assert result.exit_code == 1
24+
# assert "Security issues found" in result.stdout
25+
assert "Security warnings found" in result.stdout
2126

2227

2328
def test_publish_continues_on_no_security_violations():

0 commit comments

Comments
 (0)