Repository navigation
ergo.rego 0.5.0
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 falseorsigned: 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,matchesand the other phrases that take a list walks lists, as spec 0.5 says:pin is in $input.sbom.components.namecomparespinwith the names of the components. It works from$input,$params, the subject's fields, a parent, a part or an alias, and insidewhose,count of,sum ofandforlines. A list it can't read from every item fails every row, with the cause and wordseveryuses, and the right side is in$refsor the row'sinputsas$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, sox is in .lock.pkgs.namesays.lock.pkgs.name is missingthen, andlock.pkgs.name is missingotherwise, also for an item that isn't an object and in the names of acount ofand asum of. On aforline the message names the item with its alias, and the inputs are sorted by name. A field that is on both sides, liketags 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 asunusablebefore. -
thatpicks items by the value itself, wherewhosepicks them by a field:from: every ws that starts with "b", as spec 0.5 says. It works whereverwhosedoes, on afromline, in a check and on aforline, and a field calledthatis written.that. -
distinctafterevery,some,count oforsum ofdrops exact copies, as spec 0.5 says:every distinct sbom.componentsmakes one subject of components that are the same,count of distinct commits.author is at least 2counts each author once, andsum of distinct stages.usdadds each different amount once.1and1.0are the same value. A failed item lists the location of every copy when it was read through the subject, andnullis kept as a value. On afromline it goes afterevery. See REFERENCE.md.
Changed
- A bare field called
distinctis 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'sergosaysv0.5, itsengineversion says0.5.0, and each failed row and each violation has amessage. Besides that, a path on the right side of those phrases that goes through a list of objects used to fail every row asunusablewithit is in $input.sbom.components.name is false, and now compares or says what couldn't be read, and a$inputor$paramspath that reads into text says which value can't hold the next step. - Every condition after an
andin awhosechain starts with its ownwhoseorthat, as spec 0.5 says, sowhose a is 1 and b is 2is written wrong and becomeswhose a is 1 and whose b is 2. Reports of policies written the old way change, because they now fail$well_formed. Their problem readsa condition after and starts with whose or that. Other reports change in a few places:whose a and whose bused to fail withdoesn't parseand now reads,a is a word of the grammar: write .awhenais a word of the grammar, a field calledthatmust be written.that, awhoseorthatin the wrong place names the word that was written, and aforline with awhoseand athatgets the same cause in either order. On afromline, the$appliesrow of athatnames the item by the subject's plain name, so a subject calleditemgivesitem is "apple"where it gave.item is "apple", and a subject calledmy wgivesmy w is "apple"where it gave"my w" is "apple". itis gone, and the subject's name takes its place, as spec 0.5 says. With subjectregion,region is one of $params.allowed_regionschecks each region string, andevery tags is a stringchecks a subject that is a list. The name reads the subject on the right side of a phrase too, sosome $input.deps whose name is lib existscompares each dependency'snamewith the subjectlib. Nothing can follow the name:lib.name is 1is written wrong, withlib.name: nothing can follow lib, which means the subject: for a field called lib, write .lib.name, andnamed by libwithnamed 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 likeitem, goes in double quotes, as in"production deployment" is an object.itis an ordinary word, so a subject, a field, an alias or a part can be calledit. Reports change for every policy that wroteit: it now reads a field calledit, 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 saidit is "str", which isn't an object, and because a row'sinputsname 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_sentencesno longer writes a check with an empty path,[], asit 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. Aforline on a subject that isn't an object names it,thing is 3, which isn't an object. Aforline'swhosethat 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 saiditem 1 of xs: it is 1, which isn't an object. An$appliesrow on an item that isn't an object names the subject,t is 3, which isn't an object, and a$min_subjectsrow whosefromstops 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 saiditem 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 sayswrite .s[0]for a field calleds.first of sanditem 2 of sread an item of a subject that is a list. Follows spec 0.5. - On the left of a
whoseand aftersorted by, the subject's name is the item's field, like any bare word there, in a check, aforline and afromline, as spec 0.5 says. Sofrom: every ws whose w starts with "b", for a subject calledw, reads each item'swfield, where it read the item itself, and a quoted word of the grammar there, like"item", is a field too. On the right of awhosethe name reads the subject and.sthe item's field, socount of $input.ys whose k is s is 1compares eachkwith the subject, where it compared it with the item's owns. A row that reads a field named like the subject or a part prints it with its dot, like.kid is missinganditem 1 of .cov.xs is 1.count of "my rel"[0] is 1is written wrong withwrite ."my rel"[0], ascount of rel[0]is. Reports change for policies that write the subject's name in awhoseor aftersorted by, or read a field named like the subject or a part.
Fixed
- A
fromline whosenamed by each oflist starts at a field or a subject, liket named by each of t.keys, is written wrong, as spec 0.5 says, where it read<invalid ref> is missingwhatever the field held. Its$well_formedrow listsnamed 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
foritem that isn't an object no longer stops the report witheval_conflict_errorwhen a path reads inside it and names its key by a field, likew.k named by zzwithwa list, orw[1] named by zzandw[0].a named by zzwithwa list: the check fails with the cause the spec gives. Reports change for checks that read such a path and used to fail asnot_an_objectbecause the key field was bad. Withfor: every ws as w,assert: w named by zz is 1and input{"things": [{"id": "a", "ws": [3]}]}(nozz), the row saiditem 1 of ws is 3, which isn't an objectwith causenot_an_object, and saysitem 1 of ws: zz is missingwith causeabsent. Azzthat isnullor not text givesnullorunusablethe same way. Withassert: w[0] named by zz is 1and{"ws": [[{"a": 1}]]},not_an_objectbecameabsent, and with"zz": 3it isunusable.w[0] named by zz does not existwith{"ws": [[1]], "zz": "a"}failed asnot_an_objectbefore and now passes, asw[0].a does not existalready did. - A path that starts at a
foralias holding a list and reads a position first, likew[0].a does not existorw[0] named by zz is 1withfor: every ws as w, now reads the alias as a list, as spec 0.5 says.w[0].a does not existfails asunusablewhen the item at that position is a number or text, where it passed.w[0] named by zz is 1andw[0] named by zz does not existfail asunusablewhen the alias is a number (they saidnot_an_object) or when the item at that position is a number (they saidabsentor passed).w[0] named by zz does not existpasses when the alias isnull, where it failed asnot_an_object. The messages are the Rust engine's, likeitem 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.owitho{"a": 0, "b": [0]}, or a subject that is such an object, no longer stops the report witheval_conflict_error. The row fails asunusablewith$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
whosein afromline that reads a field named like the subject with a dot, likekids whose .kid is 1for the subjectkid, 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&, likea<b, is a subject's name everywhere a subject calleda.bis."a<b".xis written wrong and awhose "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 awhose. - 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 objectfor$params.a is 1,zz is in $params.aand$params.a named by zz is 1, and$params is 3, which isn't a listoritem 1 of $params is 3, which isn't an objectwhen 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. Acount of, aneveryor asomethat readsnullparams fails asabsentwith$params is missing, as a plain path does, where it failed asnullwith$params is null. Reports change for such checks:causegoes fromnulltoabsent. - A
forline that reads params that aren't an object, likefor: every $params as por a sentencew 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, andsum of $params.v is 1with params[3]says so too, where it saidneeds more than 15 digits. Reports change only in that message text.$params existsand$params does not existwithnullparams fail asabsentwith$params is missing, where they failed asnullwith$params is null:causegoes fromnulltoabsent. id is in $input[0].id, with subjects from$inputand 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:causegoes fromabsenttounusable.- A path on the right side of
is inand 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$inputand the input[{"id": "a"}],id is in $input.idreads$input[].idas["a"]and passes, where it failed asabsent. An item without anidfails every row asabsent, and one that isn't an object asunusable, in the words aneveryuses, likeitem 2 of $input: id is missing, and anullone asnull. The same holds in awhose, of a check, acount ofor afromline, and on aforline, sofrom: $input whose id is in $input.ok.idpicks its subjects where every$appliesrow 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,matchesanddoes not match.$refslists such a path as$input[].id, with a value and a location for each item, where it listed$input.idwithnull. A key read bynamed byornamed by each ofis 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 asunusablenow pass or fail asvalue,absent,nullor, for a subject that isn't an object,not_an_object.$input.id is in $input.id,first of $input.id is in $input.idanditem 2 of $input.id is in $input.idfail asnot_an_objectwith... is false, where they failed asunusable, because their left side reads$input.idfrom a list, which the Rego engine reads asnot_an_objectand the Rust engine asunusable, as it does for$input.id exists. A position after such a path that meets something that isn't a list, likeid is in $input.l[0]with an item whoselis"ab", fails every row asunusableand 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 asunusablewith an empty message, and now says which value isn't a list too. - A
count ofor asum ofwith awhosethat 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. Withcount of deps whose name is in $input.sbom.components.name is 1, adepsthat is an object and a component without aname, it fails asunusablewithdeps is {...}, which isn't a list, where it failed asabsentwithcount of deps whose name is in $input.sbom.components.name is 1 is false. With nodepsand a component whosenameisnull, it fails asabsentwithdeps is missing, where it failed asnull. Reports change for such checks, whatever the input is. - A subject's
fromline that reads params that aren't an object, likethings named by each of $params.ks,things named by $params.envorevery things named by $params.env, fails$min_subjectsasunusableand names the params,$params is 3, which isn't an object, as spec 0.5 says, where it failed asabsentwith$params.ks is missing. A position says what it found, like$params is 3, which isn't a listoritem 1 of $params is 3, which isn't a list of textfor$params[0]. Reports change for such policies: the$min_subjectscausegoes fromabsenttounusable, and its message changes. Withnullparams it still fails asabsentwith$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 1withxholding[[1]], names that itemit, 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.