Skip to content

v1.0.1: security hardening, single-source version, tag-driven release workflow - #4

Merged
johanbeytell1 merged 4 commits into
mainfrom
arena/b2561e59-tailclass
Nov 9, 2026
Merged

johanbeytell1 merged 4 commits into
mainfrom
arena/b2561e59-tailclass

Conversation

@johanbeytell1

Copy link
Copy Markdown
Member

Summary

Security and robustness hardening of the scanner, generator and rewriter, plus release prep for v1.0.1. TailClass parses repository content (tailclass.config.json, tailclass.map.json, existing tailclass.css, markup) and then writes files, so everything it reads is treated as untrusted input.

Security fixes

Area Change
Output paths outputCss, dictionaryFile, manifestFile coming from a config file must stay inside the project root. Previously "outputCss": "../../x.css" could overwrite files outside the project, and revert --clean could delete them. CLI paths (-o, --dict, --report) remain unrestricted. All writes go through one checked resolver.
CSS payloads Tokens containing ;, {, }, control characters or comment terminators are never emitted into @apply — they stay inline on the element. Closes CSS injection via arbitrary values such as text-[red;}html{display:none}]. Selectors, comments and dictionary metadata are re-validated in the generator.
Glob matching Replaced the regex translation with a backtracking-free dynamic-programming matcher. Patterns like ** repeated hundreds of times used to hang the process (config-driven ReDoS); they now finish in milliseconds. Malformed [ classes degrade to literals instead of throwing. Matchers are cached and patterns length-capped.
Prefixes & dictionaries classPrefix / tailwindPrefix validated (and sanitized again in the namer); dictionary label / category / elements sanitized before reaching generated CSS comments.
Overwrite protection apply refuses to overwrite a scanned source file, or a stylesheet/manifest that does not look like TailClass output, unless the new --force flag is passed.
Revert Manifest entries that are not valid class names, or whose expansion could break out of a markup attribute, are ignored; corrupt manifests produce a descriptive error.
Always excluded .git/, node_modules/, .tailclass-backup/ are never scanned, even with replaceDefaultExcludes.
Config validation Array entries, numeric thresholds, booleans, enums and prefixes produce actionable errors (Invalid exclude[1]: expected a string, received null); JSON errors name the file; unknown keys warn on stderr so --json output stays clean.

Correctness & performance

  • pointer-fine:* utilities are recognised again (stray space in the variant regex).
  • Numeric custom class names are prefixed (tc-123btn) so selectors stay valid CSS.
  • <style> / <textarea> skipping no longer lower-cases whole files (offset drift on Unicode) and no longer allocates per tag.
  • Analyzer subset matching memoises occurrence token sets and uses Set membership.
  • Glob fast paths (literal / prefix / suffix) plus scratch-buffer reuse keep large-project runs at or below previous wall-clock time.

Version & release

  • Bumped to 1.0.1; src/version.js is now the single source of truth for the generated CSS header, revert manifest, dictionary payload and CLI (previously three hard-coded "1.0.0" fallbacks could drift).
  • publish.yml (still triggered by pushing a v* tag) now validates the tag shape, fails fast unless the tagged commit is on main, checks the tag against both version files, publishes via npm OIDC trusted publishing with provenance, and creates the matching GitHub Release.

Tests

  • New test/glob.test.js (glob semantics, pathological-pattern timings, caching) and test/security.test.js (path traversal, source clobbering, CSS injection, prefix/dictionary sanitisation, config validation, manifest hardening).
  • npm run check → lint + 50 tests passing; npm run demo runs clean; npm pack --dry-run verified.

Behaviour notes for reviewers

  • Repository-supplied output paths are confined to the project root; use CLI flags for deliberate out-of-root targets.
  • Invalid configuration now fails loudly instead of being silently coerced.
  • Tokens containing CSS-breaking characters remain inline on elements (they are no longer extracted into @apply).
  • Overwriting a non-TailClass stylesheet/manifest requires --force.

Release

Once merged: git tag -a v1.0.1 -m "TailClass v1.0.1" && git push origin v1.0.1.

Arena Agent and others added 4 commits November 9, 2026 10:33
TailClass parses repository content and then writes files, so a cloned
repository can influence output paths, CSS payloads and glob patterns.
This commit fixes what an adversarial review turned up and adds
regression tests plus a written review (docs/security-review.md).

Security
- Confine config-supplied outputCss/dictionaryFile/manifestFile to the
  project root (apply/list/revert, incl. the --clean unlink path). A
  malicious tailclass.config.json could previously write, and with
  `revert --clean` delete, arbitrary files outside the project.
- Reject CSS-breaking class tokens (`;`, `{`, `}`, control chars, `*/`)
  from `@apply`; they are preserved inline on the element instead. This
  closes CSS injection via arbitrary values like
  `text-[red;}html{display:none}]`.
- Replace the regex-based glob matcher with a backtracking-free DP
  matcher: `**`-heavy patterns used to hang the process (config-driven
  ReDoS); malformed `[` classes now degrade to literals instead of
  throwing. Compiled matchers are cached and length-capped.
- Validate classPrefix/tailwindPrefix, sanitize dictionary labels,
  categories and element hints, and validate selectors/payloads in the
  generator (comment + CSS injection hardening).
- Refuse to overwrite scanned source files, or stylesheets/manifests
  that do not look like TailClass output, without --force.
- Sanitize manifest-driven reverts and report corrupt manifests.
- Always exclude .git/, node_modules/ and .tailclass-backup/, even with
  replaceDefaultExcludes.
- Validate configuration up front with actionable errors; unknown keys
  become stderr warnings; JSON errors name the offending file.

Fixes
- `pointer-fine:` variants are recognised again (stray space in the
  variant regex).
- Numeric custom class names are prefixed (tc-) so selectors stay valid.
- <style>/<textarea> skipping no longer lower-cases whole files, which
  could shift offsets on Unicode input and re-allocated per tag.
- Analyzer subset matching memoises occurrence token sets.

Performance
- Glob fast paths (literal/prefix/suffix) plus scratch-buffer reuse keep
  large-project runs at or below previous wall-clock time.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Version
- Bump to 1.0.1 (security/robustness patch on top of 1.0.0).
- Add src/version.js as the single source of truth and reuse it for the
  generated stylesheet header, revert manifest, dictionary payload and CLI,
  removing three hard-coded "1.0.0" fallbacks that could drift.
- Test asserts package.json, src/version.js and the CLI agree.

Release automation (.github/workflows/publish.yml)
- Still triggered by pushing a `v*` tag; now also:
  * validates the tag is `vX.Y.Z`,
  * fails fast unless the tagged commit is already on `main` (so nothing is
    published if the tag is created before the branch is merged),
  * verifies the tag against both package.json and src/version.js,
  * runs lint, the full test suite, the demo and `npm pack --dry-run`,
  * publishes via npm OIDC trusted publishing with provenance,
  * creates a matching GitHub Release (idempotent) with generated notes,
  * writes publish/release summaries to the job summary,
  * is serialised per tag so a re-pushed tag cannot double-publish.

Docs
- README: new "Security & Hardening (v1.0.1)" and "Releases & Versioning"
  sections, security/release badges, refreshed version strings, --force flag.
- SECURITY.md: supported-version table updated, hardening guarantees kept.
- CHANGELOG: `[1.0.1] — 2026-11-09` entry.
- CONTRIBUTING: step-by-step release checklist.
- docs/security-review.md: note that all findings are fixed in v1.0.1.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
- Remove the README "Releases & Versioning" section and the release badge;
  the tag-driven behaviour is documented in .github/workflows/publish.yml.
- Remove the CONTRIBUTING "Releasing" checklist for the same reason.
- Drop the workflow bullet from the 1.0.1 CHANGELOG entry (version bump,
  test-suite and documentation notes remain).

No workflow or version changes in this commit; v1.0.1 still releases on a
`v*` tag push.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
- Delete docs/security-review.md (findings, PoCs and remediation detail);
  the hardening behaviour it described is user-facing and stays documented
  as guarantees in SECURITY.md and the README "Configuration Safety" section.
- Drop the "Security & Hardening (v1.0.1)" summary section and the security
  badge from the README, plus review links in SECURITY.md, CHANGELOG.md and
  the README Security section.
- Remove "docs/" from the published package `files` list.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@johanbeytell1
johanbeytell1 merged commit f04a3b1 into main Nov 9, 2026
3 checks passed
@johanbeytell1
johanbeytell1 deleted the arena/b2561e59-tailclass branch November 9, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant