Skip to content

Filename-only "potentially sensitive" filter silently drops design-token files (tokens.css, tokens.contract.json) #2498

Open

Description

@singhsatyampratap

Problem

A filename-word denylist silently excludes files from the graph. It matches on the name only —
the content is never inspected — so design-system files called tokens.css / tokens.contract.json
are treated as credentials and dropped.

Discovered on a monorepo whose design tokens are generated artifacts with fixed names: the generated
tokens.css and the committed tokens.contract.json were both absent from the graph, announced by a
single line:

[graphify extract] 1 file(s) skipped as potentially sensitive (rename or move if wrongly flagged): tokens.css

Repro (deterministic on 0.9.34)

mkdir case && cd case
for n in tokens token mytokens design-tokens palette secrets credentials; do
  echo ':root{ --a: #fff; }' > "$n.css"
done
echo 'def f(): return 1' > tokens.py
echo '{"a":1}' > tokens.json
echo '{"a":1}' > plain.json
graphify extract . --code-only --no-cluster --out /tmp/out --force
[graphify extract] found 2 code, 0 docs, 0 papers, 0 images
[graphify extract] 2 file(s) not classified (no supported extension or shebang), skipped: mytokens.css, palette.css
[graphify extract] 6 file(s) skipped as potentially sensitive (rename or move if wrongly flagged):
      credentials.css, design-tokens.css, secrets.css, token.css, tokens.css, tokens.json

The rule, as observed

file outcome
tokens.css, token.css, design-tokens.css, secrets.css, credentials.css, tokens.json skipped as sensitive
mytokens.css, palette.css not matched
tokens.py not matched
plain.json indexed

Three properties, all of which look unintended:

  1. Content is never read. An empty file named token.css is skipped; a file named palette.css
    containing a real API key is not. The check cannot do what its message claims.
  2. The match is word-boundary aware, which makes it worse, not better. design-tokens matches
    (separator-delimited word tokens), mytokens does not. So the more conventionally named a
    design-token file is, the more likely it is to be dropped.
  3. It is extension-dependent. tokens.py survives; tokens.css and tokens.json do not. Same
    word, same content-blindness, different outcome. (Also note .css is not a supported code
    extension at all — palette.css came back "not classified" — yet tokens.css still went down the
    sensitive path, so the check runs ahead of classification.)

Why the suggested remedy does not work

The warning says "rename or move if wrongly flagged". For a generated artifact that is not
available: the name is fixed by the generator and asserted by a drift guard in CI. Renaming it to
please a scanner would break the build that produces it. In a design-system repo, tokens.* is close
to the single most likely filename to exist.

Suggested fix

Any of these would resolve it; roughly in order of preference:

  1. Inspect content. Gate the skip on an actual secret-shaped match (high-entropy string, known key
    prefixes, PRIVATE KEY armor). A :root{} block of hex colours is not that.
  2. Drop token from the name denylist, or require it to co-occur with a content signal.
    secret/credential/password are far less ambiguous than token, which is ordinary vocabulary
    in design systems, tokenizers, parsers and lexers.
  3. Make it overridable — honour a .graphifyignore-style allowlist, or add
    --no-sensitive-filter. Today there is no flag to opt out; I checked --help.
  4. Raise the reporting. One line in the middle of extraction output is easy to miss for a file
    that then simply does not exist in the graph. If a file is excluded, it is worth being loud.

Happy to send a PR for (1) or (3) if you have a preference on shape.

Environment

graphifyy 0.9.34, macOS (darwin 25.5.0), Python 3.12, --code-only (no LLM backend involved).

Activity

  1. sashankh commented on Aug 20, 2026

    @sashankh
    Contributor

    Reproduced on current v8 (b2cd362, 0.9.48) — still live, and the behaviour splits into two
    distinct problems that are worth separating, because only one of them actually costs you nodes.

    Probing _is_sensitive / classify_file / _is_graphable_source directly:

    file _is_sensitive classify_file in graph?
    tokens.json True FileType.CODE no — real loss
    tokens.contract.json True FileType.CODE no — real loss
    plain.json False FileType.CODE yes
    tokens.css True None no (unsupported ext anyway)
    token.css, design-tokens.css, tokens.scss True None no (unsupported ext anyway)
    mytokens.css, palette.css False None no (unsupported ext anyway)
    tokens.py, tokens.ts False FileType.CODE yes
    api_token.txt, oauth_token.json, credentials.json, .token True — no (correct)

    1. tokens.json / tokens.contract.json — genuine data loss. These classify as
    FileType.CODE, so graphify would index them (plain.json proves it), and Stage 3 drops them
    anyway. .json is in _SECRET_PRONE_DATA_EXTS, so _is_graphable_source() returns False and
    the #1666 source exemption never applies. This is the part that removes nodes from the graph.

    2. The .css cases — a reporting defect, not data loss. classify_file() returns None
    for .css/.scss today, so those files were never graph candidates. palette.css says so
    accurately ("not classified — no supported extension"), while tokens.css claims
    "skipped as potentially sensitive". Same extension, same non-outcome, two different messages,
    and only the alarming one is wrong. That is what makes this hard to diagnose — it reads like a
    security judgement about the file's contents when it is really just an unsupported extension.
    (Note this interacts with #2698, which proposes classifying .css: if that lands, category 2
    silently becomes category 1.)

    Worth noting the asymmetry in category 1 is only about the token keyword's vocabulary. The
    same machinery is right for credentials.json and oauth_token.json, and those must keep
    being caught — so "drop token from the denylist" (your option 2) would regress the cases
    #436/#718/#2106 were filed for. Any fix here has to keep oauth_token.json,
    api_token.txt, credentials.json and .token flagged while sparing tokens.json, which is
    why option 1 (a content signal gating Stage 3) or option 3 (an explicit override) look like the
    only shapes that hold.

    You offered a PR for (1) or (3) and there has been no steer since — is there a preference?
    Happy to implement whichever you'd take. For what it's worth, (3) as a .graphifyignore-style
    allowlist has the useful property that it also covers the .css half after #2698, and it does
    not require reading file contents in a module that is deliberately filename-only today.

    Repro used (no LLM backend, deterministic):

    from pathlib import Path
    import tempfile
    from graphify.detect import _is_sensitive, _is_graphable_source, classify_file
    
    d = Path(tempfile.mkdtemp())
    for n in ["tokens.json", "tokens.contract.json", "plain.json", "tokens.css",
              "tokens.py", "oauth_token.json", "credentials.json"]:
        p = d / n
        p.write_text("x", encoding="utf-8")
        print(f"{n:24} sensitive={_is_sensitive(p)!s:5} "
              f"classify={classify_file(p)!s:20} graphable={_is_graphable_source(p)}")

    Environment: v8 @ b2cd362 (0.9.48), Python 3.12.10, Windows 11 (not platform-specific).

  2. singhsatyampratap commented on Aug 20, 2026

    @singhsatyampratap
    Author

    Thanks for reproducing this and separating the two cases, that distinction makes sense.

    I wouldd prefer option 3, an explicit override/allowlist, as the first fix. I agree that simply removing token would risk regressing the legitimate credential cases.

    A .graphifyignore-style allowlist would also give users a deterministic way to include known-safe generated files such as tokens.json and tokens.contract.json, without changing the existing filename-based security behaviour.

    I’m also happy for the misleading .css reporting to be fixed separately, especially if #2698 lands.

  3. nothariharan commented on Oct 9, 2026

    @nothariharan
    Contributor

    Fixed by #4263, which supersedes #1921 (the .graphifyinclude approach, whose machinery was removed in #2112 and no longer exists on current v8).

    Both halves of the report are addressed:

    1. The .css half was a reporting defect, not data loss. .css/.scss/.less are now classified as code and run through a new CSS/SCSS design-token extractor (#3473). tokens.css is genuinely graphable now, so it is no longer reported as "skipped as potentially sensitive" for what was really an unsupported extension.

    2. tokens.json / tokens.contract.json. #3527 deliberately keeps bare plural tokens in data files excluded, so instead of weakening the default this implements the explicit override the issue asked for (option 3). A wildcard-free !path entry in .graphifyignore (or --exclude) now overrides only the Stage-3 name heuristic:

    • specific Stage-2 key files (.env, id_rsa, server.pem) and credential-store directories are never rescued;
    • glob entries (!*.json) do not rescue, so a broad opt-in cannot silently ingest credential stores;
    • entries are anchored to their own directory and matched case-sensitively; a leading / is anchor-exact;
    • only the explicit .graphifyignore/--exclude set is consulted, never .gitignore;
    • defaults are unchanged: tokens.json, oauth_token.json, api_token.txt, credentials.json, .token, secrets.json all stay skipped unless explicitly listed. oauth_token.json / api_token.txt / credentials.json / .token remain flagged.

    3. Reporting. The skip is no longer silent — GRAPH_REPORT.md gains a ## Skipped Files section naming every excluded file, and the CLI notice names the escape hatch.

    See #4263.

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