Documentation
¶
Overview ¶
Package manifests recognizes the files in a tree that declare or pin dependencies, and accounts for the ones a dependency scan did not read.
One list for every reader: a scanner deciding whether resolving nothing was a real answer, a scan reporting what it left unread, and `draugr init` deciding what a tree needs. Kept apart they disagree about what counts as a manifest, and each disagreement is a file one of them is silent about.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatOf ¶ added in v0.135.0
FormatOf names the format a path is, as Formats lists it, or "" for a path no rule recognizes. A member of a family named by one entry, requirements-dev.txt or pylock.dev.toml, is that entry. Content is not read, so a file that declares nothing still has a format.
func IsLockfile ¶ added in v0.147.0
IsLockfile reports whether a path is a lockfile, by the format FormatOf names for it.
func LicensesNotRead ¶ added in v0.166.1
LicensesNotRead is the reason for a dependency file whose packages a license scan read with none of their licenses. With no command, the file is all the scanner reads and it records none, as `records no licenses for 3 packages`. With one, the licenses are in a cache the command fills, as `licenses of 3 packages not read, run dotnet restore`.
func ParseLicensesNotRead ¶ added in v0.166.1
ParseLicensesNotRead reads a reason LicensesNotRead wrote back into its packages and command, and reports false for any other reason. A reason for several files is the same sentence over their packages, so a report that folds them into one row reads each one's count here.
func ScannerLimit ¶ added in v0.166.1
ScannerLimit reports whether reason describes what a scanner cannot read under any setting, rather than something the reader can change. Where several scanners read one file in part, another scanner's reason is shown in place of such a reason, since it can name the act that clears the row.
Types ¶
type File ¶
type File struct {
// Path is slash-separated and relative to the root that was searched.
Path string
Ecosystem string
Kind Kind
}
File is one dependency file found in a tree.
type Format ¶ added in v0.135.0
type Format struct {
// Name is the file's base name, or `*` and a suffix for a family such as `*.csproj`.
Name string
Ecosystem string
Kind Kind
}
Format is one name of dependency file Draugr recognizes.
type Kind ¶
type Kind int
Kind separates a file that names dependencies from one that pins them.
const ( // Pinned lists exact versions, and a scanner reads packages from it directly: a lockfile, // requirements.txt, go.mod, pom.xml. Pinned Kind = iota // Declared names dependencies without resolving them, so a scanner needs the lockfile beside // it: package.json, pyproject.toml, Cargo.toml, a .csproj. Declared )
type Reason ¶
type Reason string
Reason is why a dependency file contributed no packages to a scan.
const ( // NoLockfile is a declared manifest with no lockfile beside it or above it. NoLockfile Reason = "no lockfile" // Unpinned is a requirements file whose entries name no exact version. Unpinned Reason = "no pinned versions" // NotRead is a file the scan read no packages from: a name its scanner does not read, or a // format it does not support. NotRead Reason = "no packages read" // TransitiveNotReadByGrype is a pom.xml Grype read in part. Grype reads no dependency's own pom // whatever the local Maven repository holds, so no action of the reader's clears it, and it names // none. Another scanner's reason for the same file is shown in its place (see ScannerLimit). TransitiveNotReadByGrype Reason = "transitive dependencies not read by Grype" )
func PartlyPinned ¶ added in v0.165.5
PartlyPinned is the reason a requirements file a scanner took packages from was read in part: the requirements in it with no exact version, as `1 requirement not pinned: urllib3`, or `29 requirements not pinned` past namedInReason. Trivy and Grype take a package from a requirements file only where its version is pinned with `==`.
Trivy with detectionPriority: comprehensive also takes a range at its minimum version. Where the scanner took more packages than the file pins, which requirements it passed over is not recorded, and the reason counts them, as `2 requirements not read`.
ok is false for a file that is not a requirements file or pins every requirement, for one the scanner took as many packages from as it has requirements, and for one it took none from, which Account reports.
type Unread ¶
Unread is a dependency file a scan did not read, and why.
func Account ¶
Account returns the dependency files under root that are not in read, each with the reason it contributed nothing.
read holds slash-separated paths relative to root, as a scanner names the files it took packages from. A declared manifest resolved by a lockfile is not unread: the lockfile is what a scanner reads for it, and reporting both would warn about every project that is set up correctly.
A lockfile resolves its manifest when the walk holds it, so that it is reported itself if no scanner reads it, or when the walk left it out as the format with nothing in it. A file merely named like a lockfile does neither, because resolving on the name alone would leave the manifest and the lockfile both unreported with nothing read from either.