Skip to content

_is_sensitive false-positives on directory names containing "secret"/"token"/"password" as substrings #436

Closed

Description

@dannigee

Summary

graphify.detect._is_sensitive() uses substring matching on the generic secrets pattern, causing false positives on any file path that contains
secret, token, password, credential, passwd, or private_key as a substring of a larger word. This silently drops legitimate source
files from the graph with no warning to the user.

Version

graphify 0.4.23 (graphifyy on PyPI), macOS 26.4, Python 3.13

Concrete failure case

My repo is named daniel-ai-secretary and contains an AISecretary/ directory. Every file path through those directories matches (secret) inside
"secretary".

Result on my repo:

  • Without workaround: graphify update . reports 0 code files found and fails
  • With Path('.') workaround: build succeeds but 7,023 nodes from AISecretary/ are silently missing because per-file checks still flag
    AISecretary/Services/Foo.swift as sensitive

Other plausibly-affected names: any repo/dir containing tokenizer, tokenize, password_manager, credentials_ui, secretariat, tokenized_*,
etc.

Root cause

detect.py line 36:

re.compile(r'(credential|secret|passwd|password|token|private_key)', re.IGNORECASE),
                                                                                                                                                    
No word boundaries. Matches secret inside Secretary, token inside tokenizer, password inside password_manager (the last is probably desired — but
the substring match also catches safe collisions).                                                                                                  
                           
Proposed fix                                 
                                                                                                                                                    
Add \b word boundaries to that single pattern:
                                                                                                                                                    
re.compile(r'\b(credential|secret|passwd|password|token|private_key)\b', re.IGNORECASE),
                                                                                                                                                    
The other _SENSITIVE_PATTERNS entries (dotfiles, key extensions, id_rsa family, etc.) already have sufficient specificity and don't need changes.
                                                                                                                                                    
Additional observations
                                                                                                                                                    
1. When files are skipped as sensitive, the user isn't warned unless they inspect detected['skipped_sensitive'] in the dict. A repo with thousands
of skipped files produces a silently-incomplete graph.                                                                                              
2. _is_sensitive is called on the full path string (full = str(path)), so even using Path('.') as root doesn't fully help — per-file paths still
contain the offending substrings. My project's workaround is a runtime monkey-patch of _SENSITIVE_PATTERNS[2], which isn't persistable.             
3. Consider surfacing the skipped count at build-time when >N% of discovered files are dropped (e.g., WARNING: 84% of discovered files skipped as 
sensitive — check patterns).                                                                                                                        
                                                                                                                                                    
Workaround for others hitting this           
                                                                                                                                                    
import re, graphify.detect
graphify.detect._SENSITIVE_PATTERNS[2] = re.compile(                                                                                                
    r'\b(credential|secret|passwd|password|token|private_key)\b',
    re.IGNORECASE                                                                                                                                   
)

Activity

  1. added a commit that references this issue on Apr 21, 2026
    bf58d85
  2. added a commit that references this issue on Apr 23, 2026
    4738e88
  3. added a commit that references this issue on Sep 10, 2026
    c4b0400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions