Skip to content

fix: remediate CodeQL rust/path-injection, rust/non-https-url, actions/missing-workflow-permissions#7

Merged
p4gs merged 2 commits into
masterfrom
fix/GRC-codeql-remediation-clean
May 11, 2026
Merged

fix: remediate CodeQL rust/path-injection, rust/non-https-url, actions/missing-workflow-permissions#7
p4gs merged 2 commits into
masterfrom
fix/GRC-codeql-remediation-clean

Conversation

@p4gs
Copy link
Copy Markdown
Collaborator

@p4gs p4gs commented May 11, 2026

Summary

Removes the query-filters exclusions added in PR #5 and properly remediates all three CodeQL alert categories at the code level.

Changes

rust/non-https-url (1 alert — known_vendors.rs)

  • Removed #[cfg(not(test))] gate on HTTPS guard in sync_from_github — guard is now unconditional on all code paths
  • Extracted fetch_url() (private async) and apply_remote_data() (pub(crate)) so tests can exercise parse/apply logic without making HTTP requests
  • Restructured wiremock-dependent tests to call apply_remote_data() directly; converted HTTP-URL tests to assert the HTTPS enforcement error

rust/path-injection (28 alerts — 4 files)

  • known_vendors.rs find_config_dir: added file_name()=="config" allowlist barrier to CWD path; reordered file_name()/is_dir() so allowlist check precedes filesystem sink on all exe-relative paths
  • cache_commands.rs (2 sites): replaced negative-guard+continue with positive extension==json wrapping the read_to_string sink
  • dep_check.rs: inlined file_name() comparison directly into the if condition (stored bool broke CodeQL barrier tracking)
  • ner_org.rs write_if_missing: reconstruct path from canonical_parent.join(file_name) — raw path parameter never reaches File::create
  • ner_org.rs setup_onnx_runtime (Windows + non-Windows): added file_name() allowlist before exists()

actions/missing-workflow-permissions (8 alerts)

  • Added permissions: contents: read to build.yml and security.yml

Scanner config cleanup

  • Removed both query-filters exclusions from .github/codeql/codeql-config.yml

Test results

  • 3775 unit tests pass (cargo test --lib --locked)
  • cargo check --locked --all-features clean

p4gs added 2 commits May 10, 2026 20:13
…g-workflow-permissions

Remove query-filter exclusions that were masking CodeQL alerts in PR #5.
Fix all 3 alert categories at the code level.

rust/non-https-url (known_vendors.rs):
- Remove #[cfg(not(test))] gate on HTTPS guard — guard is now unconditional
- Extract fetch_url() (private) and apply_remote_data() (pub(crate)) from
  sync_from_github so tests can exercise parse/apply logic without HTTP
- Restructure 4 wiremock tests to call apply_remote_data() directly; convert
  HTTP-URL tests to assert HTTPS enforcement error message

rust/path-injection (known_vendors.rs, cache_commands.rs, dep_check.rs, ner_org.rs):
- find_config_dir: add file_name()=="config" allowlist barrier to CWD path;
  reorder file_name()/is_dir() so file_name() check precedes filesystem sink
  on all three exe-relative paths; add file_name().is_some() to env var path
- cache_commands.rs (2 sites): replace negative-guard+continue pattern with
  positive extension==json check wrapping the read_to_string sink
- dep_check.rs: inline file_name() comparison directly in if condition
  (stored bool variable broke CodeQL barrier tracking)
- ner_org.rs write_if_missing: reconstruct path from canonical_parent.join(file_name)
  so raw path parameter never reaches File::create sink
- ner_org.rs setup_onnx_runtime (Windows + non-Windows): add file_name()
  allowlist check before exists() call

actions/missing-workflow-permissions (build.yml, security.yml):
- Add top-level permissions: contents: read to both workflows

All 3775 unit tests pass. query-filters block removed from codeql-config.yml.
@p4gs p4gs merged commit b9d8609 into master May 11, 2026
21 of 22 checks passed
@p4gs p4gs deleted the fix/GRC-codeql-remediation-clean branch May 11, 2026 00:35
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