How ramkumareinstein/aid works
1. Repo shape
- This is a very small, single-purpose CLI repository.
- The core application lives in one executable script, aid, with only supporting docs and license files.
- There are no separate packages, services, or client/server boundaries; the architecture is a local filesystem scanner plus report generator.
2. Primary runtime
- The tool is a Python 3.6+ command-line program.
- It is intended to be run directly as ./aid, which makes the script itself the main entrypoint and deployment unit.
3. Top-level flow
- The user provides a target path.
- The tool recursively walks the directory tree.
- Each file is checked for binary-ness and excluded-directory membership before analysis.
- Text files are scanned for invisible or suspicious Unicode code points.
- Findings are aggregated into a per-file summary and written to a report.
4. Filesystem boundary
- The main input boundary is the target directory on disk.
- The main output boundary is a generated report file on disk, defaulting to aid-report.csv.
- The scanner also consults a configurable exclusion list, with .git excluded by default.
5. Scanning subsystem
- The scanner is focused on high-signal Unicode characters associated with smuggling and obfuscation.
- Default detection covers Unicode tags, zero-width characters, directional/bidi marks, variation selectors, invisible operators, and deprecated format controls.
- Optional modes widen the scan to classic control characters, suspicious/confusable spaces, and broader Unicode space separators.
6. Binary and noise reduction
- Before Unicode inspection, files are filtered to avoid binary content.
- The readme indicates MIME/null-byte based binary skipping, which is important because the tool is designed for source/text repositories rather than arbitrary blobs.
- This keeps the signal-to-noise ratio high and avoids expensive or misleading analysis.
7. Analysis and grouping
- The tool does more than count code points: it groups consecutive invisible characters into runs.
- It separately tracks the longest general run and the longest pure Unicode-tag run.
- It also counts unique code points and tallies character names, which makes the output useful for both security triage and forensic review.
8. Suspicion classification
- Each file is assigned a suspicion level based on run length and total invisible-character volume.
- The severity model is hierarchical: critical is driven by very long runs, while high/medium/info are determined by shorter runs and totals.
- This makes the output suitable for prioritizing review rather than just listing raw detections.
9. Unicode tag decoding path
- Unicode tag sequences are treated specially because they can encode hidden ASCII payloads.
- The scanner decodes those sequences into readable notes in the report.
- That creates an important data path from raw code points to human-readable hidden text.
10. Report generation subsystem
- The final aggregation is rendered in one of three formats: CSV, JSON, or plain text.
- CSV is the default and is structured for easy filtering by downstream tooling.
- JSON supports programmatic consumption, while text is optimized for human review and console output.
11. CLI and operational controls
- The command-line interface exposes the target path, output path, format selection, progress display, and optional scan toggles.
- --verbose affects user feedback during traversal, not the analysis itself.
- The scan-mode flags control how broad the detector is, which is a key architectural boundary between “strict/high-signal” and “broader/noisier” scanning.
12. Integration style
- The repository is self-contained and has no external runtime dependencies or network services mentioned in the docs.
- The only notable external touchpoints are the local filesystem, the Python runtime, and whatever shell tooling a user applies to the generated report afterward.
13. How to diagram it
- A good architecture diagram would show: user/CLI input → recursive file traversal → exclusion/binary filter → Unicode detection and grouping → severity classification and tag decoding → report writer.
- The most important boundaries are input directory, analysis pipeline, and report output, with optional scan modes branching off the detection stage.
Main entry points: aid aid · README.md README
Components 20
Runtime
Executable scanner and its analysis pipeline.
- aid · Main executable script and deployment unit for the scanner.
aid - CLI args · Parses target path, output path, format selection, progress, and scan toggles.
- Target dir · User-supplied directory tree to inspect.
- Tree walk · Recursively visits files under the target directory.
- Exclusions · Skips excluded directories such as .git before analysis.
- Binary skip · Avoids binary or blob-like files using null-byte or MIME-style checks.
- Unicode scan · Scans text files for invisible and suspicious Unicode code points.
- Scan modes · Optional switches broaden the detector to control characters, suspicious spaces, and broader separators.
- Run groups · Groups consecutive invisible characters into runs and tracks the longest general and tag-specific runs.
- Tag decode · Decodes Unicode tag sequences into readable hidden-text notes.
- Severity · Assigns suspicion levels from info to critical based on run length and total invisible volume.
- Char stats · Counts unique code points and tallies character names for review.
- Summary · Combines per-file findings into a report-ready result set.
- Report writer · Writes results as CSV, JSON, or plain text.
- CSV · Default machine-friendly report format for filtering and downstream tooling.
- JSON · Programmatic report format for structured consumption.
- Text · Human-readable report format for console or manual review.
- Report file · Generated report on disk, defaulting to aid-report.csv.
Connections 23
- aid → CLI args: parses · The executable script interprets command-line options and input paths.
- CLI args → Target dir: selects · CLI provides the root directory to scan.
- CLI args → Scan modes: toggles · Flags widen or narrow the detection scope.
- Target dir → Tree walk: walks · The scanner recursively traverses the chosen directory tree.
- Tree walk → Exclusions: filters · Excluded directories are skipped during traversal.
- Exclusions → Binary skip: passes files · Remaining candidates are checked for binary content before inspection.
- Binary skip → Unicode scan: text only · Only text-like files proceed to Unicode analysis.
- Scan modes → Unicode scan: expands scope · Optional modes broaden which code points are detected.
- Unicode scan → Run groups: groups · Detected invisible characters are clustered into runs.
- Unicode scan → Tag decode: decodes · Unicode tag sequences are converted into readable notes.
- Run groups → Severity: scores · Run lengths and total invisible volume drive severity.
- Unicode scan → Char stats: counts · The scanner tallies unique code points and names.
- Severity → Summary: feeds · Per-file severity contributes to the final summary.
- Char stats → Summary: feeds · Character statistics are included in the aggregate result.
- Tag decode → Summary: feeds · Decoded hidden text is carried into the report.
- Summary → Report writer: renders · Aggregated findings are formatted for output.
- Report writer → CSV: writes · CSV is the default report format.
- Report writer → JSON: writes · JSON is available for programmatic use.
- Report writer → Text: writes · Plain text supports human review.
- CSV → Report file: persists · The generated report is written to disk.
- JSON → Report file: persists · The generated report is written to disk.
- Text → Report file: persists · The generated report is written to disk.
- README → aid: documents · README explains how to run the CLI and interpret outputs.