MCPcopy Index your code
hub / github.com/SourceCode-AI/aura / test_output_path_formatting

Function test_output_path_formatting

tests/test_outputs.py:207–230  ·  view source on GitHub ↗

Test that in the output, the paths have correct output formats: - Archives have $ denoting the path afterwards indicate the path in the archive - Paths should not contain parts of a temporary directory

(scan_file, fixtures)

Source from the content-addressed store, hash-verified

205)
206@pytest.mark.e2e
207def test_output_path_formatting(scan_file, fixtures):
208 """
209 Test that in the output, the paths have correct output formats:
210 - Archives have $ denoting the path afterwards indicate the path in the archive
211 - Paths should not contain parts of a temporary directory
212 """
213 temp_prefix = tempfile.gettempdir()
214 output = fixtures.scan_test_file(scan_file)["detections"]
215
216 for hit in output:
217 location: str = hit.get("location")
218 signature: str = hit["signature"]
219 if not location:
220 continue
221
222 # Check that the location does not expose temporary directory used by aura
223 assert not location.startswith(temp_prefix)
224 # Location should never end only with $ which is special character in aura indicating path inside the archive
225 # `$` should always be followed by a path
226 assert not location.endswith(f"$")
227 # Having scan_file multiple times in a location might indicate a problem with stripping path via parent
228 assert location.count(scan_file) <= 1
229 # Signatures also should not contain any temporary paths
230 assert temp_prefix not in signature
231
232
233@pytest.mark.e2e

Callers

nothing calls this directly

Calls 2

scan_test_fileMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected