-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
docs: add agent guidance and threat model #2828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
smoelius
wants to merge
1
commit into
validatorjs:master
Choose a base branch
from
trail-of-forks:add-agents-threat-model
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+310
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # AGENTS.md | ||
|
|
||
| This file provides guidance to AI coding agents working with this repository. | ||
|
|
||
| ## Project map | ||
|
|
||
| - validator.js is a single-package npm project for string validation and sanitization. | ||
| - `src/index.js` defines the public exports, and `src/lib` contains validators, sanitizers, normalizers, converters, static format data, and shared utilities. | ||
| - `test/validators.test.js` contains most API tests; additional test files cover browser builds and individual utilities. | ||
| - `README.md` is the primary public API reference. Update it when documented API behavior or options change. | ||
| - `build-browser.js` creates the browser bundle. Babel creates the Node and ES module distributions. | ||
| - `index.js`, `lib/`, `es/`, `validator.js`, and `validator.min.js` are generated. Do not edit or commit them manually. | ||
| - The published package contains only the generated distributions, `README.md`, `LICENSE`, and package metadata listed in the `files` field of `package.json`. | ||
| - validator.js has no runtime dependencies. The packages in `devDependencies` are used only to build, lint, and test the project. | ||
|
|
||
| ## Branching and pull requests | ||
|
|
||
| - Normal changes target `master`. | ||
| - Keep changes focused on the reported behavior. Avoid unrelated API, formatting, generated-file, or data-table changes. | ||
| - Bug fixes should include a focused regression test that fails before the fix and passes afterward. | ||
| - Follow the style of recent commit and pull-request titles; the repository does not define a separate title convention in `CONTRIBUTING.md`. | ||
|
|
||
| ## Install and build | ||
|
|
||
| - Use npm for the official build and test path. | ||
| - Install development dependencies with `npm install --legacy-peer-deps`, as documented in `CONTRIBUTING.md` and used by CI. | ||
| - Prefer Node.js 24 for local work. CI also tests Node.js 8, 10, 12, 14, 16, 18, 20, and 22, so avoid syntax or runtime APIs unsupported by the intended compatibility range. | ||
| - Run `npm run build` to generate the Node, ES module, and browser distributions. | ||
| - Do not infer a source change from generated output alone; inspect the corresponding file under `src/`. | ||
|
|
||
| ## Test | ||
|
|
||
| - `npm test` is the broad local check. Its `pretest` lifecycle builds every distribution and runs ESLint before the Mocha suite. | ||
| - `npm run lint` checks `src/` and `test/`. | ||
| - `npm run build` builds all published forms without running the tests. | ||
| - For a focused Mocha run, use `npm test -- --grep '<test name>'`; retain the broad `npm test` run before considering a code change complete. | ||
| - Tests use Mocha, Babel, and nyc. Coverage output under `coverage/` and `.nyc_output/` is generated and should not be committed. | ||
| - When changing a shared helper, identify and test its public callers. A helper-level test alone does not establish public API behavior. | ||
| - When changing behavior represented in multiple distributions, verify the source implementation and the relevant generated form rather than editing generated files. | ||
| - If a command fails during setup, distinguish dependency, Node-version, filesystem, and tooling failures from product-code failures before changing source. | ||
|
|
||
| ## Change discipline | ||
|
|
||
| - Preserve documented behavior and compatibility outside the stated scope of a change. | ||
| - Prefer the smallest root-cause fix over special-casing a reported input. | ||
| - Keep static locale and format data changes separate from algorithm changes when practical. | ||
| - Do not update generated distributions manually; building and publishing generate them from `src/`. | ||
| - Do not commit, push, publish a package or advisory, open an issue or pull request, or disclose private security material unless explicitly authorized. | ||
|
|
||
| ## Documentation and threat model | ||
|
|
||
| - Update `README.md` when a public API, option, return contract, or documented limitation changes. | ||
| - Read `SECURITY.md` for the supported-version and vulnerability-reporting policy. | ||
| - Read `THREAT_MODEL.md` before triaging a suspected vulnerability. | ||
| - Do not place private advisories, unpublished findings, reporter information, or private bug-hunt results in public documentation. | ||
|
|
||
| ## Security analysis | ||
|
|
||
| - Before describing a finding as novel, check open and closed issues, pull requests, published advisories, available approved private advisory material, tests, documentation, changelog entries, and relevant source history. | ||
| - Prefer rejecting speculative candidates over presenting unsupported security conclusions. | ||
|
|
||
| ## Security reproduction standards | ||
|
|
||
| - Start from a documented or reasonably supported public API invocation. An internal-helper test alone does not demonstrate public behavior unless that helper is itself public. | ||
| - State the exact arguments, options, environment, expected documented behavior, observed behavior, independent security effect, and relevant preconditions. | ||
| - Add a focused regression test that expresses the expected correct behavior rather than an incidental implementation detail. | ||
| - Run the test against the unchanged implementation and confirm that it fails for the stated reason. If the behavior does not reproduce, stop and report the evidence instead of modifying source. | ||
| - After a fix, confirm that the focused test passes and run `npm test` to check the generated builds, lint, and existing test suite. | ||
| - Keep reproductions safe, local, bounded, self-contained, and readable. Do not contact external targets or run unbounded denial-of-service payloads. | ||
| - Report the root cause, files changed, before-and-after results, compatibility effects, assumptions, and remaining limitations. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make this guidance more generic and avoid hard-coding the CI matrix and future maintenance?
For example:
This keeps the guidance current as the supported Node.js versions and CI matrix change.