Skip to content

v0.5.0

Choose a tag to compare

@f-klement f-klement released this 21 Nov 22:52
· 16 commits to main since this release

Breaking changes

  • errata check runs program and generated checks that last took a second or more in copies of the repository in the user's cache, ignored files included up to 32 MiB
  • a program check that writes a file a later check reads needs in_place: true
  • SIGTERM and SIGHUP stop errata check as an interrupt does

Changes

  • errata --version prints the version, the same line as errata version, and exits 0.
  • In a container on cgroup v2 whose CPU limit is not a whole number of cores, or is one core, errata check runs as many rules at once as the limit's whole cores, at least one, where it ran one more and was throttled; set GOMAXPROCS to choose the number yourself.
  • A PHP array() with one element, such as array('x'), now reads as a list of one, as the short form does; it read as the bare value before, so a path that takes each member of it selected nothing.
  • New: an extractor kind errata does not build in is a plugin, an executable named errata-ext-NAME that provides the kind NAME under extract:. Its entry takes file, files and max_bytes as any kind does, plus the keys the plugin declares, and errata decodes it as strictly as a built in kind's. The first two plugins are csv and hcl, released on tags of their own; the README's Plugins section shows how to install one. A plugin's release is tagged errata-ext-NAME/vX.Y.Z, holds an executable for each platform and a checksums file, and is never marked latest, so errata's own release stays the latest.
  • New: errata plugin install NAME downloads errata-ext-NAME for your system from errata's GitHub releases, checks it against the checksums file of its release, sends it the describe request, keeps it in the user's cache under its sha256, and writes its version and the sha256 of every platform's build into errata.lock. Commit the lock. Without a version it installs the version the lock pins, else the newest release that is neither a draft nor a prerelease. With no name it installs every plugin the lock pins, which is what a CI job runs before errata check.
  • errata plugin install --vendor also writes every platform's build the lock pins, the release's notices file and errata's LICENSE into .errata/plugins, so CI with no network runs from the commit. Once .errata/plugins exists, a run looks there alone, so every install vendors as --vendor does and says so.
  • errata plugin install refuses a release or a mirror that serves other bytes than the lock pins, and never rewrites a pin: delete the plugin's lines from errata.lock to pin it anew. It writes the lock last, only when every plugin installed, and otherwise exits 2 with the lock unchanged. A download is at most 256 MiB, and fails when the server sends no answer within 30 s or nothing for 60 s.
  • To install from a mirror of the releases, set ERRATA_PLUGIN_SOURCE or pass --source, an https URL with no user name or password, or a file:/// directory. A mirror holds each release's files in a directory named by its tag, such as errata-ext-csv/v0.1.0/. It installs only versions the lock already pins; pass --trust-source to let it choose a new pin, or pin each version once from GitHub. GITHUB_TOKEN is sent to api.github.com alone, when errata looks up the newest release.
  • A plugin from elsewhere installs from a file with errata plugin install --file ./errata-ext-NAME, or from an https URL with --url and the --sha256 you give, which errata checks before it keeps the file. --platform adds another platform's build of a URL pin, and --replace lets either take the place of a release the lock pins. Such a plugin speaks plugin protocol 1, which docs/plugin-protocol.md specifies.
  • errata.lock, at the top of the repository, pins one plugin build a line: name, version, platform and sha256, then source=file or source=url: for a plugin from elsewhere. errata reads it whenever the config loads. A repository without one uses no plugin and loads as before; a line errata cannot read, or a file over 1 MiB, makes the config fail to load, naming the line. errata plugin install keeps the comment lines at the top of the file and drops every other comment.
  • A run never downloads a plugin and never looks on PATH. It runs the build the lock pins from .errata/plugins when the repository has that directory, else from errata/plugins in the user's cache directory, and checks its sha256 against the lock first. errata does not start a build that is missing, is a symbolic link or lies below one, has another sha256 (the message names both), or is not pinned for the platform errata runs on; every rule with an entry of its kind is then unknown, naming the plugin, the path and the errata plugin install command to run.
  • errata starts a plugin once for each request, in an empty directory of its own, with an environment that holds only GOMAXPROCS, GOMEMLIMIT and GOGC when errata has them, and SYSTEMROOT on Windows. A CI job's tokens, HOME and PATH do not reach it. On Linux and macOS errata kills the plugin's process group when the request ends.
  • A plugin has 10 s to describe itself and to build its entries, and 30 s for each extract. Its stdout is bounded at 1 MiB for describe, 32 MiB for build and an amount set by max_bytes for extract, and its stderr at 1 MiB, of which a message quotes the last 256 bytes. Past a bound errata stops the plugin and the rule is unknown, naming the bound; for describe and build, every rule with an entry of its kind is.
  • A plugin that fails to describe itself, or speaks no protocol version errata speaks, makes every rule with an entry of its kind unknown; the message names the versions each side speaks. An entry the plugin refuses makes the config fail to load, quoting the plugin. A reply errata refuses makes the rule unknown, and so do more than 100000 values, or values past max_bytes, where a plugin's key and condition count too. Such a rule still loads, and errata refuses none of its extractors as unused.
  • New: the csv plugin, errata-ext-csv, reads a cell of a CSV or TSV file as Go's encoding/csv parses RFC 4180. column names the column of the value, and where maps columns to the text the row must hold; each matching row gives a value, and with no where every row does. header: false reads the first row as data and names columns by number from 1, written as a string such as column: "2". dialect is csv or tsv, and delimiter takes another single character, such as a semicolon.
  • The csv plugin makes the rule unknown, naming the file and the line, for a row that does not parse, a header that lacks the column or a where key or names one twice, a file with no header row, a value's cell that is not UTF-8, and more than 100000 values. A where that matches no row finds no value, so allow_empty decides. A lone CR does not end a row, so a file saved as Excel for Mac's CSV (Macintosh) is one row: save it with LF or CRLF line ends. A UTF-8 byte order mark is not part of the first cell.
  • New: the hcl plugin, errata-ext-hcl, reads an attribute of a Terraform .tf or .tfvars file, a Packer .pkr.hcl file or a Nomad job file with HashiCorp's hcl/v2 native syntax, and evaluates nothing. Its key path walks dotted names through attributes, block types and each label in turn, as in variable.region.default or resource.aws_instance.web.ami. A quoted name in brackets reads a name with a dot, a number in brackets a list element, and a star in brackets every attribute, label, item or element.
  • The hcl plugin returns a literal as the file writes it: a number as written, true, false, null, or a string with no interpolation, its escapes read. It returns anything else as the file wrote it, marked not literal: a reference, an interpolation, a function call, an operator, a conditional, a for expression, and a value the path goes past, such as a key inside a merge call. With a star in the path, each value's condition is the path it matched. A path that selects nothing finds no value, so allow_empty decides; one that ends at a block, an object or a list makes the rule unknown.
  • The hcl plugin makes the rule unknown, naming the file and the line, for a file HCL cannot parse, and before parsing for a file nested more than 1000 levels deep, a number longer than 1000 bytes, a template that costs more than 128 times max_bytes to join, or more tokens than one for every 16 bytes of max_bytes, 2097152 at the default. An ordinary file of about 4.5 MB or more passes the token limit: raise max_bytes on its entry. More than 100000 values make the rule unknown too.
  • The hcl plugin reads one request's files for at most 20 s, below errata's 30 s for an extract, and past that the rule is unknown with the plugin's message naming the file and the 20 s. This bound depends on the machine, unlike the others, so a file that parses in close to 20 s can pass on a fast runner and fail on a slow or busy one.
  • When an interrupt, SIGTERM or SIGHUP stops errata, each program check, generated check, rule and plugin that had not finished is unknown with a message that starts cancelled: and names the signal. A program check said before that it did not finish within its timeout, which it had not reached. An interrupt while the config loads stops the plugins describing and building in the same way.
  • The html reader, and HTML in Markdown, read a frameset and a frame tag as a browser does. A frameset replaces the page's body only while the body holds nothing but blanks and elements such as a div or a heading; errata then reads nothing after it but comments, so a code, section or table target there finds no value. Anywhere else both tags are ignored and open no element, where errata read them as ordinary elements and took text a browser drops.
  • A regex whose best literal is a single byte, such as the colon of a token pattern of digits, a colon and word characters, now searches only the lines that hold both that byte and a run of four or more characters of one ASCII class the pattern needs, when the pattern cannot cross a line. Such a rule reads a large source tree in less time.
  • A record field whose path selects more than 100000 values is refused with a message that names the file once, at its start, where it named it twice.
  • errata list prints in_place for a check that sets it, and the JSON listing gives every program check and generated check an in_place key, false when the check sets none.
  • errata records how long each program and generated check took in durations.json, in the repository's directory of the user's cache (errata under $XDG_CACHE_HOME, ~/.cache, ~/Library/Caches or %LocalAppData%), and copies a check only when the record is missing or its last run took 1 s or more. A CI job that starts with an empty cache copies every such check.
  • errata check runs every check in the repository, as before, when a copy cannot pay or cannot match the tree: fewer than two program or generated checks that took a second or more, a pool of one worker, no git on the PATH as in errata's image, a repository with no commit, submodules, a sparse checkout, a filter attribute such as Git LFS, ignored files over 32 MiB, or GIT_DIR and its kin set, as a git hook sets them.
  • A check in a copy sees the copy's path as its working directory and ERRATA_ROOT, files modified when the copy was made, and the copy's git config, in which an includeIf "gitdir:..." section or a relative include.path may not apply. A copy errata cannot make, such as on a full disk, leaves its check unknown, saying why.

All commits since v0.4.2: https://github.com/f-klement/errata/compare/v0.4.2..v0.5.0