Skip to content

fix: flag Paddle code patterns as warnings#925

Open
mldangelo-oai wants to merge 2 commits intomainfrom
mdangelo/codex/paddle-severity-audit
Open

fix: flag Paddle code patterns as warnings#925
mldangelo-oai wants to merge 2 commits intomainfrom
mdangelo/codex/paddle-severity-audit

Conversation

@mldangelo-oai
Copy link
Copy Markdown
Contributor

@mldangelo-oai mldangelo-oai commented Apr 10, 2026

Summary

This PR fixes a false-clean aggregate result in the Paddle scanner. Paddle model files containing shared dangerous code patterns such as os.system, eval, and import os were reported only as INFO findings, so aggregate scans returned success and exit code 0 even though suspicious executable content was detected.

Root Cause

PaddleScanner used IssueSeverity.INFO for both exact binary code-pattern hits and suspicious string-pattern hits. ModelAudit intentionally treats INFO as informational and does not return a security exit code for it. That made real code-execution indicators visible in the report but invisible to exit-code based automation.

Changes

  • Raise Paddle binary code-pattern detections from INFO to WARNING.
  • Raise Paddle suspicious string-pattern detections from INFO to WARNING.
  • Add direct severity coverage for .pdmodel and .pdiparams detections.
  • Add aggregate regressions proving suspicious Paddle artifacts now return exit code 1.
  • Preserve the existing .pdiparams false-positive suppressions for hex escapes and dunder-like binary noise.
  • Update the Unreleased changelog.

Validation

  • uv run pytest tests/scanners/test_paddle_scanner.py: 12 passed
  • uv run ruff format modelaudit/ packages/modelaudit-picklescan/src packages/modelaudit-picklescan/tests tests/
  • uv run ruff check --fix modelaudit/ packages/modelaudit-picklescan/src packages/modelaudit-picklescan/tests tests/
  • uv run mypy modelaudit/ packages/modelaudit-picklescan/src packages/modelaudit-picklescan/tests tests/: 432 source files clean
  • uv run pytest -n auto -m "not slow and not integration" --maxfail=1: 2432 passed, 1100 skipped, 16 warnings
  • uv run ruff check modelaudit/ packages/modelaudit-picklescan/src packages/modelaudit-picklescan/tests tests/
  • uv run ruff format --check modelaudit/ packages/modelaudit-picklescan/src packages/modelaudit-picklescan/tests tests/
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes
    • Paddle suspicious code pattern detection now produces proper security exit codes
    • Updated severity classification for Paddle pattern detections to warning level for improved security alerting

@mldangelo-oai mldangelo-oai enabled auto-merge (squash) April 10, 2026 21:23
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

Warning

Rate limit exceeded

@mldangelo-oai has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 25 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 19 minutes and 25 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: efd74e79-85d3-4533-aec5-73428d75a566

📥 Commits

Reviewing files that changed from the base of the PR and between e23d6db and 6516909.

📒 Files selected for processing (1)
  • tests/scanners/test_paddle_scanner.py

Walkthrough

The Paddle scanner now reports suspicious code patterns with WARNING severity instead of INFO, enabling security exit codes. Tests are updated to verify WARNING severity and confirm exit code 1 is returned for suspicious code detections.

Changes

Cohort / File(s) Summary
Paddle Scanner Severity Update
CHANGELOG.md, modelaudit/scanners/paddle_scanner.py
Elevated severity level for suspicious code pattern detection from INFO to WARNING, documented in changelog. Applies to both binary and string pattern detection checks (rule S902).
Test Coverage for Security Exit Codes
tests/scanners/test_paddle_scanner.py
Enhanced existing test to verify WARNING severity for suspicious patterns. Added two new tests for .pdmodel and .pdiparams files that confirm suspicious code patterns trigger security exit code 1. Updated remaining test assertion to verify WARNING severity across all detected issues.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A cautious hop, the scanner grows wise,
WARNING bells now ring for suspicious codes that rise,
Exit code one for security's sake,
The Paddle path clearer, safer to take! 🛡️

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: flag Paddle code patterns as warnings' accurately describes the main change: elevating Paddle pattern detection severity from INFO to WARNING to ensure security exit codes are produced.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mdangelo/codex/paddle-severity-audit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 10, 2026

Workflow run and artifacts

Performance Benchmarks

Compared 6 shared benchmarks with a regression threshold of 15%.
Status: 0 regressions, 0 improved, 6 stable, 0 new, 0 missing.
Aggregate shared-benchmark median: 682.29ms -> 684.80ms (+0.4%).

Benchmark Target Size Files Baseline Current Change Status
tests/benchmarks/test_scan_benchmarks.py::test_detect_file_format_safe_pickle safe_model.pkl 49.4 KiB 1 127.5us 136.2us +6.8% stable
tests/benchmarks/test_scan_benchmarks.py::test_validate_file_type_pytorch_zip state_dict.pt 1.5 MiB 1 42.0us 43.1us +2.6% stable
tests/benchmarks/test_scan_benchmarks.py::test_scan_safe_pickle safe_model.pkl 49.4 KiB 1 28.18ms 28.54ms +1.3% stable
tests/benchmarks/test_scan_benchmarks.py::test_scan_mixed_directory mixed-corpus 1.7 MiB 54 135.97ms 136.73ms +0.6% stable
tests/benchmarks/test_scan_benchmarks.py::test_scan_pytorch_zip state_dict.pt 1.5 MiB 1 34.85ms 34.95ms +0.3% stable
tests/benchmarks/test_scan_benchmarks.py::test_scan_duplicate_directory duplicate-corpus 840.0 KiB 81 483.11ms 484.40ms +0.3% stable

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/scanners/test_paddle_scanner.py`:
- Around line 38-48: The test
test_paddle_suspicious_pdmodel_aggregate_exit_code_is_security_finding should be
hardened to assert ScanResult severity flags: after calling
scan_model_directory_or_file in that test (and similarly in the other aggregate
test around lines 126-136), add assertions that result.has_warnings is True and
result.has_errors is False to lock in the intended semantics (WARNING should set
has_warnings but not has_errors); update references around the test function
name and the result variable so the assertions run alongside the existing
determine_exit_code(result) and severity checks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8b522ab4-eced-49db-971f-4caa118f350c

📥 Commits

Reviewing files that changed from the base of the PR and between f285a05 and e23d6db.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • modelaudit/scanners/paddle_scanner.py
  • tests/scanners/test_paddle_scanner.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant