Unpinned dependency
Unpinned dependency. An unpinned version ("a": "latest"). Installs will differ from machine to machine.
This is how the comment reads inline, under the flagged line.
Why it matters
latest, * and bare package names pull whatever is newest at install time, so a build can break with no change in the repo.
What to do
Pin a version range (^1.4.2) and commit the lockfile.
Examples
"left-pad": "latest"
"left-pad": "^1.3.0"
What it catches
It reads a pattern on each line, aware of strings and comments. Languages: Any file. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
package.json
{
"dependencies": {
"a": "latest"
}
}requirements.txt
requests
Left alone
package.json
{
"dependencies": {
"a": "^1.2.0"
}
}requirements.txt
requests==2.32.0
Research
Dependencies pinned to `*`, `latest` or an open range. A compromised release gets pulled in automatically.
- X post by tshemsedinov
- skill: code-review
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"unpinned-dependency"
],
"severity": {
"unpinned-dependency": "low"
}
}
}