ggshield
ggshield copied to clipboard
Move scanning code outside of scannable.py
Description
The scan.scannable
module contains deals with two topics: scanning documents and loading documents from files or commits.
The scanning code should be moved in a separate, secret-specific, module to make scannable
simpler. This would improve the architecture of our code, for example the IAC commands use scannable
to read files, but they do not need the secret-oriented scan()
method.
Proposed reorganization
- Rename the
scan
package tosecret
. This matches the existingiac
package. - Move secret scanning code from
scannable
tosecret
:-
Files.scan()
to asecret.scan_files(files: Files)
function. -
Result
,Error
,Results
assecret
classes.
-
- Move
ScanCollection
tooutput
: it can't go tosecret
because it containsiac_result
, so it's not secret-only - Move the rest of
scannable
(File
,Commit
,Files
,CommitFile
and related parsing code) tocore.scannable
- (Bonus) Move
utils.ScanMode
tosecret
, rename itSecretScanMode
- (Bonus) Move
utils.Filemode
tocore.scannable
, or remove it if it turns out we don't need it
Definition of Done
-
scan
package does not exist anymore -
core.scannable
does not depend on any secret-related code (no import of pygitguardian, no network-related code) -
core.scannable
does not depend on any iac-related code
A suggestion : should we rename ScanMode
to SecretScanMode
for clarity and in case we introduce different modes for other scanning capabilities ?
A suggestion : should we rename
ScanMode
toSecretScanMode
for clarity and in case we introduce different modes for other scanning capabilities ?
Good idea, amending the description.