Skip to content

ergo.rego 0.5.0

Choose a tag to compare

@github-actions github-actions released this 05 Nov 23:32
· 196 commits to main since this release
rego-v0.5.0
5fa8f24

New

  • Every failed row has a message, a line of plain text that says what Ergo found, as spec 0.5 says: approver is "ana", and author is "ana", item 2 of tests: ok is false or signed: signature is missing; reviewed: reviewer is missing. A row that passed has none. Each violation carries the message of its row.

  • A path on the right side of is one of, contains, matches and the other phrases that take a list walks lists, as spec 0.5 says: pin is in $input.sbom.components.name compares pin with the names of the components. It works from $input, $params, the subject's fields, a parent, a part or an alias, and inside whose, count of, sum of and for lines. A list it can't read from every item fails every row, with the cause and words every uses, and the right side is in $refs or the row's inputs as $input.sbom.components[].name. A leading dot reads the subject's field. The message and the input name keep the dot only when a part, a parent subject or an alias has the same first name, so x is in .lock.pkgs.name says .lock.pkgs.name is missing then, and lock.pkgs.name is missing otherwise, also for an item that isn't an object and in the names of a count of and a sum of. On a for line the message names the item with its alias, and the inputs are sorted by name. A field that is on both sides, like tags contains none of tags, is said once, tags is ["a"], where a message that repeats a clause used to say it twice. No policy that worked changes, except that last one, because a right side that walks a list failed as unusable before.

  • that picks items by the value itself, where whose picks them by a field: from: every ws that starts with "b", as spec 0.5 says. It works wherever whose does, on a from line, in a check and on a for line, and a field called that is written .that.

  • distinct after every, some, count of or sum of drops exact copies, as spec 0.5 says: every distinct sbom.components makes one subject of components that are the same, count of distinct commits.author is at least 2 counts each author once, and sum of distinct stages.usd adds each different amount once. 1 and 1.0 are the same value. A failed item lists the location of every copy when it was read through the subject, and null is kept as a value. On a from line it goes after every. See REFERENCE.md.

Changed

  • A bare field called distinct is written wrong, as spec 0.5 says: write .distinct. Reports of a policy with such a field change, because they now fail $well_formed.
  • This version follows spec 0.5, so a policy says ergo_spec: v0.5. Reports change for every policy: the report's ergo says v0.5, its engine version says 0.5.0, and each failed row and each violation has a message. Besides that, a path on the right side of those phrases that goes through a list of objects used to fail every row as unusable with it is in $input.sbom.components.name is false, and now compares or says what couldn't be read, and a $input or $params path that reads into text says which value can't hold the next step.
  • Every condition after an and in a whose chain starts with its own whose or that, as spec 0.5 says, so whose a is 1 and b is 2 is written wrong and becomes whose a is 1 and whose b is 2. Reports of policies written the old way change, because they now fail $well_formed. Their problem reads a condition after and starts with whose or that. Other reports change in a few places: whose a and whose b used to fail with doesn't parse and now reads, a is a word of the grammar: write .a when a is a word of the grammar, a field called that must be written .that, a whose or that in the wrong place names the word that was written, and a for line with a whose and a that gets the same cause in either order. On a from line, the $applies row of a that names the item by the subject's plain name, so a subject called item gives item is "apple" where it gave .item is "apple", and a subject called my w gives my w is "apple" where it gave "my w" is "apple".
  • it is gone, and the subject's name takes its place, as spec 0.5 says. With subject region, region is one of $params.allowed_regions checks each region string, and every tags is a string checks a subject that is a list. The name reads the subject on the right side of a phrase too, so some $input.deps whose name is lib exists compares each dependency's name with the subject lib. Nothing can follow the name: lib.name is 1 is written wrong, with lib.name: nothing can follow lib, which means the subject: for a field called lib, write .lib.name, and named by lib with named by lib: lib is the whole subject, so it can't name a key. A field called like the subject is written with a dot, .lib. A name with a space, or one that is a word of the grammar like item, goes in double quotes, as in "production deployment" is an object. it is an ordinary word, so a subject, a field, an alias or a part can be called it. Reports change for every policy that wrote it: it now reads a field called it, or fails with a missing field, until it names the subject. They change for plain names too, because a row that read a value that isn't an object names the subject by its name, deployment is "str", which isn't an object, where it said it is "str", which isn't an object, and because a row's inputs name a subject that is a list or a value by its name, and a field named like the subject with a dot, .lib. See REFERENCE.md.
  • ergo.as_sentences no longer writes a check with an empty path, [], as it is "x". It leaves the check as it was, and it is written wrong: write the check with the subject's name.
  • A message no longer says the subject is ..., and names the subject or where a read starts instead. A for line on a subject that isn't an object names it, thing is 3, which isn't an object. A for line's whose that meets an item that isn't an object names the item without a colon, item 1 of xs is 1, which isn't an object, where it said item 1 of xs: it is 1, which isn't an object. An $applies row on an item that isn't an object names the subject, t is 3, which isn't an object, and a $min_subjects row whose from stops before its first step names where it starts, $input is null, or the parent subject, artifact is "x", which isn't a list or an object. A child subject read from an item of its parent names the parent, item 1 of p is missing, where it said item 1 of $input is missing. Reports of plain policies change in those messages.
  • The subject's name followed by brackets, s[0], is written wrong like any other step, and the problem says write .s[0] for a field called s. first of s and item 2 of s read an item of a subject that is a list. Follows spec 0.5.
  • On the left of a whose and after sorted by, the subject's name is the item's field, like any bare word there, in a check, a for line and a from line, as spec 0.5 says. So from: every ws whose w starts with "b", for a subject called w, reads each item's w field, where it read the item itself, and a quoted word of the grammar there, like "item", is a field too. On the right of a whose the name reads the subject and .s the item's field, so count of $input.ys whose k is s is 1 compares each k with the subject, where it compared it with the item's own s. A row that reads a field named like the subject or a part prints it with its dot, like .kid is missing and item 1 of .cov.xs is 1. count of "my rel"[0] is 1 is written wrong with write ."my rel"[0], as count of rel[0] is. Reports change for policies that write the subject's name in a whose or after sorted by, or read a field named like the subject or a part.

Fixed

  • A from line whose named by each of list starts at a field or a subject, like t named by each of t.keys, is written wrong, as spec 0.5 says, where it read <invalid ref> is missing whatever the field held. Its $well_formed row lists named by each of takes a list from $params or $input, so it can't start at a field or a subject, and the subject has no other rows.
  • A for item that isn't an object no longer stops the report with eval_conflict_error when a path reads inside it and names its key by a field, like w.k named by zz with w a list, or w[1] named by zz and w[0].a named by zz with w a list: the check fails with the cause the spec gives. Reports change for checks that read such a path and used to fail as not_an_object because the key field was bad. With for: every ws as w, assert: w named by zz is 1 and input {"things": [{"id": "a", "ws": [3]}]} (no zz), the row said item 1 of ws is 3, which isn't an object with cause not_an_object, and says item 1 of ws: zz is missing with cause absent. A zz that is null or not text gives null or unusable the same way. With assert: w[0] named by zz is 1 and {"ws": [[{"a": 1}]]}, not_an_object became absent, and with "zz": 3 it is unusable. w[0] named by zz does not exist with {"ws": [[1]], "zz": "a"} failed as not_an_object before and now passes, as w[0].a does not exist already did.
  • A path that starts at a for alias holding a list and reads a position first, like w[0].a does not exist or w[0] named by zz is 1 with for: every ws as w, now reads the alias as a list, as spec 0.5 says. w[0].a does not exist fails as unusable when the item at that position is a number or text, where it passed. w[0] named by zz is 1 and w[0] named by zz does not exist fail as unusable when the alias is a number (they said not_an_object) or when the item at that position is a number (they said absent or passed). w[0] named by zz does not exist passes when the alias is null, where it failed as not_an_object. The messages are the Rust engine's, like item 1 of ws: item 1 of w is 1, which isn't an object.
  • A right side that is an object holding values of different kinds, like x is in $input.o with o {"a": 0, "b": [0]}, or a subject that is such an object, no longer stops the report with eval_conflict_error. The row fails as unusable with $input.o is {"a": 0, "b": [0]}, which isn't a list, the same as for an object whose values are all of one kind.
  • A whose in a from line that reads a field named like the subject with a dot, like kids whose .kid is 1 for the subject kid, reads the item's field, as spec 0.5 says, where it read the subject. Reports of such policies change.
  • A subject named with a quote, a backslash, <, > or &, like a<b, is a subject's name everywhere a subject called a.b is. "a<b".x is written wrong and a whose "a<b" names the item's field ."a<b", where both were read as if the subject had another name. A quoted subject name that is a word of the syntax, like "item", is printed as written, with its quotes, in the problem and in a whose.
  • A check that reads params that aren't an object names them in its message, as spec 0.5 says, where it said the check was false: $params is 3, which isn't an object for $params.a is 1, zz is in $params.a and $params.a named by zz is 1, and $params is 3, which isn't a list or item 1 of $params is 3, which isn't an object when the path starts with a position, like $params[0].a named by zz is 1. Reports change only in that message text, for params that are a number, text, a boolean or a list. A count of, an every or a some that reads null params fails as absent with $params is missing, as a plain path does, where it failed as null with $params is null. Reports change for such checks: cause goes from null to absent.
  • A for line that reads params that aren't an object, like for: every $params as p or a sentence w is in $params.v, names them, $params is 3, which isn't an object, where it said the check was false or named the list it walked, and sum of $params.v is 1 with params [3] says so too, where it said needs more than 15 digits. Reports change only in that message text. $params exists and $params does not exist with null params fail as absent with $params is missing, where they failed as null with $params is null: cause goes from null to absent.
  • id is in $input[0].id, with subjects from $input and the input [{"id": "a"}], says $input[0].id is "a", which isn't a list, as the spec and the Rust engine say, where it said $input[0].id is missing. Reports change for such checks: cause goes from absent to unusable.
  • A path on the right side of is in and the other phrases that take a list walks the items of an input that is a list, as spec 0.5 says and the Rust engine does. With subjects from $input and the input [{"id": "a"}], id is in $input.id reads $input[].id as ["a"] and passes, where it failed as absent. An item without an id fails every row as absent, and one that isn't an object as unusable, in the words an every uses, like item 2 of $input: id is missing, and a null one as null. The same holds in a whose, of a check, a count of or a from line, and on a for line, so from: $input whose id is in $input.ok.id picks its subjects where every $applies row failed. It holds for every phrase that takes a list: is one of, is not one of, contains, does not contain, contains all of, contains none of, contains some of, does not contain all of, matches and does not match. $refs lists such a path as $input[].id, with a value and a location for each item, where it listed $input.id with null. A key read by named by or named by each of is read as before and isn't walked, and what one check reads doesn't change how another reads. Reports change for such checks on an input that is a list: rows that failed as unusable now pass or fail as value, absent, null or, for a subject that isn't an object, not_an_object. $input.id is in $input.id, first of $input.id is in $input.id and item 2 of $input.id is in $input.id fail as not_an_object with ... is false, where they failed as unusable, because their left side reads $input.id from a list, which the Rego engine reads as not_an_object and the Rust engine as unusable, as it does for $input.id exists. A position after such a path that meets something that isn't a list, like id is in $input.l[0] with an item whose l is "ab", fails every row as unusable and says so, item 2 of $input: l is "ab", which isn't a list. On an input that is an object the same position, like $input.w.id[0], failed as unusable with an empty message, and now says which value isn't a list too.
  • A count of or a sum of with a whose that can't read a ref fails with the first cause in the order of causes, as spec 0.5 says and the Rust engine does, where the ref's cause won. With count of deps whose name is in $input.sbom.components.name is 1, a deps that is an object and a component without a name, it fails as unusable with deps is {...}, which isn't a list, where it failed as absent with count of deps whose name is in $input.sbom.components.name is 1 is false. With no deps and a component whose name is null, it fails as absent with deps is missing, where it failed as null. Reports change for such checks, whatever the input is.
  • A subject's from line that reads params that aren't an object, like things named by each of $params.ks, things named by $params.env or every things named by $params.env, fails $min_subjects as unusable and names the params, $params is 3, which isn't an object, as spec 0.5 says, where it failed as absent with $params.ks is missing. A position says what it found, like $params is 3, which isn't a list or item 1 of $params is 3, which isn't a list of text for $params[0]. Reports change for such policies: the $min_subjects cause goes from absent to unusable, and its message changes. With null params it still fails as absent with $params.ks is missing.
  • The message of a count whose path goes through an item that is a list, like count of x[0] named by zz is 1 with x holding [[1]], names that item it, where it left the name empty: item 1 of x: item 1 of it is 1, which isn't an object. Reports change only in that message text.