folder trust: harden the shared warning pattern and its contract test (from #9519 review)

Open Beginner friendly
#9,520 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active

Research direction

Start with packages/protocol/src/folder-trust-warnings.ts and packages/server/tests/folder-trust-warning-contract.test.js. Read how FOLDER_TRUST_BLOCKING_WARNING is built and how the contract test tracks prefixes from real scans. Make the three requested safety, coverage, and naming changes; run the contract test both normally and with a name filter to confirm coverage remains independent.

Written by the indexing model from the issue text.

Description

from-review tech-debt testing

Context

Filed from: the round 1 review of #9519 (closes #9516), at head 5a44e9a0f. The review approved, with no critical findings. The points below do not block that PR.

#9519 moved the folder-trust warning prefixes into one module, packages/protocol/src/folder-trust-warnings.ts. The daemon builds its warnings from it, and store-core's split uses its FOLDER_TRUST_BLOCKING_WARNING. A real-scan contract test, packages/server/tests/folder-trust-warning-contract.test.js, guards it.

1. The prefixes go into new RegExp unescaped

FOLDER_TRUST_BLOCKING_WARNING joins FOLDER_TRUST_WARNING_PREFIX values into a new RegExp(...) without escaping. All four prefixes are plain letters and spaces today, so it is safe. A future prefix containing ., ( or ? would silently change what the pattern matches, or throw when protocol is imported. The .source pin test would notice only if someone edits it by hand in the same change.

Acceptance: escape each prefix (a small escapeRegExp), or assert in the protocol test that every prefix matches /^[A-Za-z ]+$/. Either way, a prefix with a metacharacter must go red.

2. The contract test's coverage check depends on the earlier cases

The last case in folder-trust-warning-contract.test.js asserts that every prefix was produced by some real scan. It reads a seen set that the earlier cases fill, so a run with --test-name-pattern or --test-only makes it red for the wrong reason. A normal file run is sound.

Acceptance: the coverage case builds its own scans, or is folded into a single case that both scans and checks coverage.

3. Nit: an inverted name

In the same test file, NOT_ROOT is true when the host is Windows or the process runs as root. The behaviour is correct (the chmod case skips in both), but the name reads backwards. Rename it, for example CANNOT_CHMOD_UNREADABLE.

Dominant language
JavaScript
Stars
7
Forks
1
Avg merge
2h 3m
Merged PRs (30d)
333

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from blamechris/chroxy

All issues in blamechris/chroxy

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.