|
| 1 | +# TruffleHog Process Flows |
| 2 | + |
| 3 | +## Scans |
| 4 | + |
| 5 | +## Data Flow |
| 6 | + |
| 7 | +```mermaid |
| 8 | +flowchart LR |
| 9 | + SourceDecomposition["`**Source Decomposition** |
| 10 | +
|
| 11 | +Breaking up the locations that we are looking _for_ secrets into small chunks`"] |
| 12 | +
|
| 13 | + DetectorMatching{Chunk<br/>to<br/>Detector<br/>Matching} |
| 14 | + |
| 15 | + SecretDetection["`**Secret Detection** |
| 16 | +
|
| 17 | +Finding secrets in these chunks and (optionally) verifying whether they are live`"] |
| 18 | +
|
| 19 | + ResultNotification["`**Result Notification** |
| 20 | +
|
| 21 | +Enriching results with metadata and (usually) printing to console`"] |
| 22 | + |
| 23 | + SourceDecomposition -- chunks --> DetectorMatching |
| 24 | + DetectorMatching -- matched chunks --> SecretDetection |
| 25 | + SecretDetection -- results --> ResultNotification |
| 26 | +``` |
| 27 | + |
| 28 | +#### Source Decomposition |
| 29 | + |
| 30 | +```mermaid |
| 31 | +flowchart TD |
| 32 | + subgraph Source |
| 33 | + direction TB |
| 34 | + SourceDescription("`**(1)** Sources are top level places we find data/files/text to _scan_`") |
| 35 | + GitSource["git Source"] |
| 36 | + GitHubSource["GitHub Source"] |
| 37 | + FilesystemSource["File System Source"] |
| 38 | + PostmanSource["Postman Source"] |
| 39 | + end |
| 40 | +
|
| 41 | + subgraph Unit |
| 42 | + direction TB |
| 43 | + UnitDescription("`**(2)** Units are natural subdivisions of Sources, but still quite large`") |
| 44 | + FilesystemUnit[Directory] |
| 45 | + GitUnit[Git Repository] |
| 46 | + end |
| 47 | +
|
| 48 | + subgraph Chunk |
| 49 | + direction TB |
| 50 | + ChunkDescription("`**(3)** Chunks are the smallest units that we decompose our chunks into, and are subsequent passed on to detection`") |
| 51 | + FilesystemChunk[file contents] |
| 52 | + GitRepositoryChunk["`git log diff hunks`"] |
| 53 | + PostmanChunk[data chunk] |
| 54 | + end |
| 55 | +
|
| 56 | +
|
| 57 | + SourceDescription -- decomposed into --> UnitDescription |
| 58 | + UnitDescription -- further decomposed into --> ChunkDescription |
| 59 | +
|
| 60 | +
|
| 61 | + GitSource -- cloned locally<br />if not already local --> GitUnit |
| 62 | + GitHubSource -- cloned locally --> GitUnit |
| 63 | + PostmanSource -- Most sources\ndon't use units --> PostmanChunk |
| 64 | + FilesystemSource --> FilesystemUnit |
| 65 | +
|
| 66 | + GitUnit -- git log -p --> GitRepositoryChunk |
| 67 | + FilesystemUnit --> FilesystemChunk |
| 68 | +
|
| 69 | + style SourceDescription fill:#89553e |
| 70 | + style UnitDescription fill:#89553e |
| 71 | + style ChunkDescription fill:#89553e |
| 72 | +``` |
| 73 | + |
| 74 | +#### Chunk to Detector Matching |
| 75 | + |
| 76 | +```mermaid |
| 77 | +flowchart LR |
| 78 | +
|
| 79 | +
|
| 80 | + KeywordMatching["`**Keyword Matching** |
| 81 | +_(Aho-Corsick)_ |
| 82 | +
|
| 83 | +Match chunks to detectors based on the presence of specific keywords in the chunk`"] |
| 84 | + |
| 85 | + chunks --> KeywordMatching --> detectors |
| 86 | +``` |
| 87 | + |
| 88 | +#### Secret Detection |
| 89 | + |
| 90 | +```mermaid |
| 91 | +flowchart LR |
| 92 | +
|
| 93 | +subgraph Detector |
| 94 | + direction RL |
| 95 | + subgraph DetectorDescription[" "] |
| 96 | + DetectorDescriptionText["`Detectors are the bits that actually check for the existence of a secret in a chunk, and (optionally) verify it`"] |
| 97 | + ExampleDetectors["`Example Detectors: |
| 98 | + * AWS |
| 99 | + * Azure |
| 100 | + * Twilio`"] |
| 101 | + end |
| 102 | + |
| 103 | + subgraph DetectorResponsibility[" "] |
| 104 | + direction LR |
| 105 | +
|
| 106 | + De-Dupe-Detectors["`**De-Dupe-Detectors** |
| 107 | +
|
| 108 | +If multiple detectors keyword-match on the same chunk, we have some logic that chooses which detector will verify found secret (so we don't duplicate verification requests to externa APIs)`"] |
| 109 | +
|
| 110 | + CollectMatches["`**Collect Matches** |
| 111 | +
|
| 112 | +Detector specific regexes are run against the matched chunks, resulting in unverified secrets`"] |
| 113 | + VerifyMatches["`**Verify Matches** |
| 114 | +
|
| 115 | +Optionally, observed unverified secrets are verified by attempting to use them against live services`"] |
| 116 | + |
| 117 | + De-Dupe-Detectors -- deduped detectors --> CollectMatches |
| 118 | + CollectMatches -- regex matched chunks --> VerifyMatches |
| 119 | + end |
| 120 | + |
| 121 | + style DetectorDescription fill:#89553e |
| 122 | + style DetectorDescriptionText fill:#89553e |
| 123 | +end |
| 124 | +``` |
| 125 | + |
| 126 | +#### Result Notification |
| 127 | + |
| 128 | +```mermaid |
| 129 | +flowchart LR |
| 130 | +
|
| 131 | + Dispatcher["`**Dispatcher** |
| 132 | +
|
| 133 | +Results, verified or otherwise, are sent to a dispatcher to be sent to whichever place we're updating about the |
| 134 | +results -- usually the command line.`"] |
| 135 | + |
| 136 | + results --> Dispatcher --> output |
| 137 | +``` |
| 138 | + |
0 commit comments