Skip to content

Conversation

@6d7a
Copy link
Contributor

@6d7a 6d7a commented Nov 13, 2025

Context

When calling ggshield secret scan ./dir-containing-invalid-symlink on a directory that contains an invalid symlink, the command fails. This PR fixes it.

Closes #1144.

What has been done

  • Catch exceptions caused by invalid symlinks during scans and log a warning.
  • Add test case for invalid symlinks.

Validation

  • create a test target for the symlink: touch /tmp/testfile
  • create a symlink to the test file: ln -s /tmp/testfile
  • delete the symlink target: rm /tmp/testfile
  • run ggshield secret scan path --recursive .
  • confirm that ggshield logs the skipped file it did not find

PR check list

  • As much as possible, the changes include tests (unit and/or functional)
  • If the changes affect the end user (new feature, behavior change, bug fix) then the PR has a changelog entry (see doc/dev/getting-started.md). If the changes do not affect the end user, then the skip-changelog label has been added to the PR.

@6d7a 6d7a requested a review from a team as a code owner November 13, 2025 09:11
@6d7a 6d7a self-assigned this Nov 13, 2025
@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.96%. Comparing base (705db4e) to head (1776b65).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1147      +/-   ##
==========================================
+ Coverage   91.94%   91.96%   +0.02%     
==========================================
  Files         144      144              
  Lines        6196     6199       +3     
==========================================
+ Hits         5697     5701       +4     
+ Misses        499      498       -1     
Flag Coverage Δ
unittests 91.96% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Applying a mark to a fixture function is deprecated and became a hard error in pytest 9. See https://docs.pytest.org/en/stable/deprecations.html#applying-a-mark-to-a-fixture-function
Copy link
Collaborator

@agateau-gg agateau-gg left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@6d7a 6d7a merged commit a4076b9 into main Nov 13, 2025
30 checks passed
@6d7a 6d7a deleted the kevinwestphal/handle-invalid-symlink branch November 13, 2025 10:15
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.

Invalid symlink causes error in the scan

3 participants