Skip to content

Commit a4076b9

Browse files
authored
Merge pull request #1147 from GitGuardian/kevinwestphal/handle-invalid-symlink
Handle Invalid Symlinks During Scans
2 parents 705db4e + 1776b65 commit a4076b9

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!--
2+
A new scriv changelog fragment.
3+
4+
Uncomment the section that is right (remove the HTML comment wrapper).
5+
For top level release notes, leave all the headers commented out.
6+
-->
7+
8+
<!--
9+
### Removed
10+
11+
- A bullet item for the Removed category.
12+
13+
-->
14+
<!--
15+
### Added
16+
17+
- A bullet item for the Added category.
18+
19+
-->
20+
<!--
21+
### Changed
22+
23+
- A bullet item for the Changed category.
24+
25+
-->
26+
<!--
27+
### Deprecated
28+
29+
- A bullet item for the Deprecated category.
30+
31+
-->
32+
33+
### Fixed
34+
35+
- Skip invalid symlinks with warning during scans.
36+
<!--
37+
38+
### Security
39+
40+
- A bullet item for the Security category.
41+
42+
-->

ggshield/verticals/secret/secret_scanner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ def _start_scans(
161161
except NonSeekableFileError:
162162
scanner_ui.on_skipped(scannable, "file cannot be seeked")
163163
continue
164+
except FileNotFoundError:
165+
scanner_ui.on_skipped(scannable, "file not found")
166+
continue
164167

165168
if content:
166169
if (

tests/functional/conftest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ def _start_no_quota_gitguardian_api(host: str, port: int):
107107

108108

109109
@pytest.fixture
110-
@pytest.mark.allow_hosts(["localhost"])
111110
def slow_gitguardian_api() -> Generator[str, None, None]:
112111
host, port = "localhost", 8123
113112
server_process = Process(target=_start_slow_gitguardian_api, args=(host, port))
@@ -120,7 +119,6 @@ def slow_gitguardian_api() -> Generator[str, None, None]:
120119

121120

122121
@pytest.fixture
123-
@pytest.mark.allow_hosts(["localhost"])
124122
def no_quota_gitguardian_api() -> Generator[str, None, None]:
125123
host, port = "localhost", 8124
126124
server_process = Process(target=_start_no_quota_gitguardian_api, args=(host, port))

tests/unit/verticals/secret/test_secret_scanner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def test_scan_patch(client, cache, name: str, input_patch: str, expected: Expect
134134
"EMPTY",
135135
"TOO_BIG",
136136
"BINARY",
137+
"FILE_NOT_FOUND",
137138
],
138139
)
139140
def test_scanner_skips_unscannable_files(client, fs, cache, unscannable_type: str):
@@ -151,6 +152,8 @@ def test_scanner_skips_unscannable_files(client, fs, cache, unscannable_type: st
151152
mock.is_longer_than.return_value = True
152153
elif unscannable_type == "BINARY":
153154
mock.is_longer_than.side_effect = DecodeError
155+
elif unscannable_type == "FILE_NOT_FOUND":
156+
mock.is_longer_than.side_effect = FileNotFoundError
154157

155158
scanner_ui = Mock(spec=ScannerUI)
156159

0 commit comments

Comments
 (0)