Skip to content

feat(rust_dependency_audit): add organization rust dependency audit tool with github pages reporting - #58

Open
srinivasugithub wants to merge 7 commits into
eclipse-score:mainfrom
bgsw-contrib:feat/rust-dependency-audit
Open

srinivasugithub wants to merge 7 commits into
eclipse-score:mainfrom
bgsw-contrib:feat/rust-dependency-audit

Conversation

@srinivasugithub

Copy link
Copy Markdown

Summary

This PR implements the Rust Dependency Audit tool and GitHub Pages reporting workflow as requested in eclipse-score/score#1839.

Context & Motivation

Across the eclipse-score organization, multiple repositories maintain Rust implementations (baselibs, kyron, lifecycle, persistency, scrample, feo, etc.). To ensure that dependencies are consistent and centrally managed in eclipse-score/score-crates (the central single source of truth), this tool automates:

  1. Scanning all repositories across the organization for Rust projects (Cargo.toml and Cargo.lock in root, workspaces, and submodules).
  2. Extracting all declared and locked crate dependencies.
  3. Cross-referencing crates and versions against eclipse-score/score-crates (MODULE.bazel crate.spec and BUILD alias).
  4. Classifying dependencies into:
    • MANAGED: Defined in score-crates with matching version.
    • VERSION_MISMATCH: Defined in score-crates, but repository requests a different version.
    • UNMANAGED: Direct external crate not yet onboarded into score-crates.
  5. Generating reports:
    • Interactive GitHub Pages Dashboard (index.html): Self-contained web app with live metrics, search filter, status filter, and per-repository breakdown tables.
    • Machine-readable JSON (rust_dependency_audit.json): For CI/CD automation or SBOM tools.
    • Markdown summary (rust_dependency_audit.md): Formatted for GitHub issue comments and Step Summaries.
  6. Automated GitHub Actions workflow (.github/workflows/rust-dependency-audit.yml) for scheduled weekly runs and on-demand deployment to GitHub Pages.

Changes

  • Added rust_dependency_audit to workspace members in pyproject.toml.
  • Added rust_dependency_audit package with cli.py, github_client.py, cargo_parser.py, score_crates.py, auditor.py, reporter.py, BUILD, and README.md.
  • Added unit tests covering all components (test_cargo_parser.py, test_score_crates.py, test_auditor.py, test_reporter.py, test_cli.py).
  • Added wheel build and CLI smoke test to .github/workflows/tests.yml.
  • Added GitHub Pages deployment workflow .github/workflows/rust-dependency-audit.yml.
  • Added entry to root README.md.

Testing & Validation

  • Ran full test suite across the workspace: 374 passed tests.
  • Checked formatting and linting: ruff check and ruff format passed with 0 errors.
  • Copyright header check: passed cleanly with score-copyright.
  • Local smoke test: wheel built and verified via uv build and score-rust-dependency-audit --help.
  • Validated organization scan against local repository checkouts.

Relates to eclipse-score/score#1839

@srinivasugithub
srinivasugithub marked this pull request as ready for review October 8, 2026 13:43
@srinivasugithub
srinivasugithub requested a balanced review from Copilot October 8, 2026 13:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Audit accuracy, incomplete repository discovery, and HTML injection risks must be addressed before deployment.

15 open findings
What changed in this PR

Adds the organization-wide Rust dependency audit requested by eclipse-score/score#1839.

Changes:

  • Adds Cargo and score-crates parsing, auditing, and multi-format reporting.
  • Adds comprehensive unit tests and packaging integration.
  • Adds scheduled GitHub Pages reporting and CI smoke tests.
File Description
uv.lock Registers the new workspace package.
rust_dependency_audit/​tests/​test_score_crates.py Tests reference parsing.
rust_dependency_audit/​tests/​test_reporter.py Tests report generation.
rust_dependency_audit/​tests/​test_cli.py Tests CLI behavior.
rust_dependency_audit/​tests/​test_cargo_parser.py Tests Cargo parsing.
rust_dependency_audit/​tests/​test_auditor.py Tests dependency classification.
rust_dependency_audit/​src/​score_crates.py Parses the central crate reference.
rust_dependency_audit/​src/​reporter.py Generates JSON, Markdown, and HTML reports.
rust_dependency_audit/​src/​github_client.py Discovers repositories and files.
rust_dependency_audit/​src/​cli.py Implements audit orchestration.
rust_dependency_audit/​src/​cargo_parser.py Parses Cargo manifests and lockfiles.
rust_dependency_audit/​src/​auditor.py Classifies and aggregates dependencies.
rust_dependency_audit/​src/​__init__.py Defines the internal package.
rust_dependency_audit/​README.md Documents usage and features.
rust_dependency_audit/​pyproject.toml Configures packaging and CLI entry point.
rust_dependency_audit/​BUILD Adds Bazel targets.
rust_dependency_audit/​__main__.py Adds module execution support.
rust_dependency_audit/​__init__.py Defines the top-level package.
README.md Lists the new tool.
pyproject.toml Adds the workspace member.
.gitignore Ignores generated outputs.
.github/​workflows/​tests.yml Builds and smoke-tests the wheel.
.github/​workflows/​rust-dependency-audit.yml Runs audits and deploys GitHub Pages.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread rust_dependency_audit/src/auditor.py Resolved
Comment thread rust_dependency_audit/src/auditor.py Resolved
Comment on lines +70 to +71
is_git = "git" in spec
is_path = "path" in spec

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in cargo_parser.py and auditor.py. DeclaredDependency now records git_url and git_rev. In auditor.py, _git_matches_spec() cross-references declared Git repositories and commit
revisions against ScoreCrateSpec.git and rev. Verified with unit test test_audit_git_dependencies

Comment thread rust_dependency_audit/src/cli.py Resolved
Comment thread rust_dependency_audit/src/reporter.py Resolved
Comment thread rust_dependency_audit/src/cli.py Resolved
Comment thread rust_dependency_audit/src/reporter.py Resolved
Comment thread rust_dependency_audit/src/reporter.py Resolved
…iscovery, and security

- score_crates: use balanced parentheses scanner ignoring comments/strings for crate.spec

- cargo_parser: handle renamed dependencies (package = ...) and preserve git_url/rev

- auditor: preserve version requirement operators (=, ~), track multiple lockfile versions, and verify lockfile mismatches

- github_client: handle git tree truncation fallback and discover git submodule manifests

- reporter: escape embedded JSON script data and sanitize DOM inputs to prevent XSS

- reporter & cli: dynamically use reference_repo in reports and count non-Rust repos

- cli & workflow: ensure default reports bundle is always written in out_dir and append summary separately

- tests: add comprehensive test suite covering all review findings

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread rust_dependency_audit/src/auditor.py Resolved
Comment thread rust_dependency_audit/src/cli.py Resolved
Comment thread rust_dependency_audit/src/reporter.py Resolved
kandukurisrinivasu and others added 2 commits October 16, 2026 16:05
…reference validation, and scanner correctness

- auditor: unconditionally merge lockfile-only crates and track resolved versions and git sources
- cli: require at least one parsed crate specification in central reference
- score_crates: add cycle detection in get_spec to prevent alias recursion errors
- score_crates: track lexical context from index 0 to ignore specs in comments and strings
- github_client: propagate REST API errors on auth, rate limit, and network failures
- reporter: add persistent aria-label to search input for accessibility
- tests: add unit tests for all review findings

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment on lines +54 to +58
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ORG="${{ inputs.organization || 'eclipse-score' }}"
REF_REPO="${{ inputs.reference_repo || 'eclipse-score/score-crates' }}"
Comment on lines +123 to +124
_, clean_spec = _parse_requirement(spec_ver)
return res_ver.strip() == clean_spec
Comment on lines +220 to +223
if lock.name not in collected_crates:
git_urls: set[str] = set()
git_revs: set[str] = set()
if lock.source and lock.source.startswith("git+"):
Comment on lines +84 to +86
# Handle rate limiting or not found without leaking tokens
if e.code == 404:
return None
Comment on lines +256 to +267
try:
sub_entries = self._fetch_tree_entries(
sub_owner, sub_repo, sub_sha
)
for sub_item in sub_entries:
if sub_item.get("type") == "blob":
full_sub_p = (
f"{sub_path}/{sub_item.get('path', '')}"
)
paths.append(full_sub_p)
except Exception:
pass
self, owner: str, repo: str, path: str, branch_or_sha: str
) -> str | None:
"""Helper to fetch raw file content from GitHub raw or REST API."""
url = f"https://raw.githubusercontent.com/{owner}/{repo}/{branch_or_sha}/{path}"
Comment on lines +186 to +189
for toml in repo_data.cargo_tomls:
for dep in toml.dependencies:
# Exclude internal path dependencies
if dep.is_path or dep.name in internal_crate_names:
@AlexanderLanin

Copy link
Copy Markdown
Member

this would belong to crates repo, wouldnt it?

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.

4 participants