No gem is fetched from git
ruby/no-git-dependencies@v1
No gem the manifests declare is fetched from a git repository rather than from a gem source. The Gemfile is Ruby rather than a declaration and is read by pattern, so a git gem that is found is a real finding, but finding none is not proof that there is none: a gem added inside a condition, a loop or an eval is not seen.
| Id | ruby/no-git-dependencies |
| Version | v1 |
| Category | ruby |
| Default severity | warning |
| Interpreter | python3 |
| Timeout | 30 seconds |
| Violations tolerated | 0 |
| Collects | ruby |
Collectors
This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.
| Collector | Gathers | Inputs it is given |
|---|---|---|
ruby | The Bundler project in the project directory: the Ruby version it asks for, the gem sources it resolves from, the gems each manifest declares with their groups and origins, and the lock file beside them. The Gemfile is Ruby rather than a declaration, so what it declares conditionally is not seen and scanned says so. | projectDir |
The inputs above are this guardrail's own, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.
Configuration
{
"guardrails": {
"failOn": "error",
"comment": true,
"checks": [
{
"use": "ruby/no-git-dependencies@v1",
"severity": "warning",
"with": {
"projectDir": "."
},
"exemptions": []
}
]
}
}Inputs
| Input | Description | Default | Environment variable |
|---|---|---|---|
projectDir | Directory holding the project, relative to the directory the CLI runs in. | . | GUARDRAIL_INPUT_PROJECTDIR |
How to fix
Depend on a published release from the source the rest of the build resolves from:
gem "acme-widget", "~> 2.1"Where a fork is the only thing carrying the fix, publish that fork as a gem rather than pointing the build at a branch. A git: or github: gem is fetched from a repository somebody can force push, rename or make private, so an update installs code no index ever published and a build that worked yesterday can stop resolving entirely.
More in ruby
ruby/lockfile-committed. The project commitsGemfile.lock, so an install of the same commit resolves the same gem versions.ruby/single-gem-source. TheGemfileresolves gems from at most one source, and that source is one the repository trusts. TheGemfileis Ruby rather than a declaration and is read by pattern, so a second source that is found is a real finding, but finding one source is not proof that there is only one: a source named inside a condition, a loop or anevalis not seen.ruby/version-declared. The project declares the Ruby version it is built and run against, and that version is no older than the configured floor.