ggshield icon indicating copy to clipboard operation
ggshield copied to clipboard

Move scanning code outside of scannable.py

Open agateau-gg opened this issue 2 years ago • 2 comments

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

  1. Rename the scan package to secret. This matches the existing iac package.
  2. Move secret scanning code from scannable to secret:
    • Files.scan() to a secret.scan_files(files: Files) function.
    • Result, Error, Results as secret classes.
  3. Move ScanCollection to output: it can't go to secret because it contains iac_result, so it's not secret-only
  4. Move the rest of scannable (File, Commit, Files, CommitFile and related parsing code) to core.scannable
  5. (Bonus) Move utils.ScanMode to secret, rename it SecretScanMode
  6. (Bonus) Move utils.Filemode to core.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

agateau-gg avatar Aug 30 '22 16:08 agateau-gg

A suggestion : should we rename ScanMode to SecretScanMode for clarity and in case we introduce different modes for other scanning capabilities ?

pierrelalanne avatar Aug 31 '22 07:08 pierrelalanne

A suggestion : should we rename ScanMode to SecretScanMode for clarity and in case we introduce different modes for other scanning capabilities ?

Good idea, amending the description.

agateau-gg avatar Sep 06 '22 07:09 agateau-gg