mirror of
https://github.com/github/codeql.git
synced 2025-12-21 03:06:31 +01:00
File hashing is now done internally in `SwiftFileInterception` (and exported as a `getHashOfRealFile` function for future use in linkage awareness), and using a per-process in-memory cache. The persistent caching of paths is removed, so the solution is now robust against input file changes during the build. For the same reason, the hash to artifact mapping have the symlinks reversed now. The artifacts themselves are stored using the hash as filenames, and the original paths of the artifacts are reacreated in the scratch dir with symlinks mostly for debugging purposes (to understand what artifact each hash corresponds to, and to follow what was built by the extractor).
22 lines
712 B
Python
22 lines
712 B
Python
from create_database_utils import *
|
|
from subprocess import check_call
|
|
from hashlib import sha256
|
|
from pathlib import Path
|
|
|
|
run_codeql_database_create([
|
|
'./build.sh',
|
|
], lang='swift')
|
|
|
|
with open('hashes.expected', 'w') as expected:
|
|
for f in sorted(Path().glob("*.swiftmodule")):
|
|
with open(f, 'rb') as module:
|
|
print(f.name, sha256(module.read()).hexdigest(), file=expected)
|
|
|
|
with open('hashes.actual', 'w') as actual:
|
|
hashes = [(s.name, s.resolve().name) for s in Path("db/working/swift-extraction-artifacts/store").iterdir()]
|
|
hashes.sort()
|
|
for module, hash in hashes:
|
|
print(module, hash, file=actual)
|
|
|
|
check_call(['diff', '-u', 'hashes.expected', 'hashes.actual'])
|