Skip to content

Commit

Permalink
Don't crash when logging an update query without osVersion or buildID (
Browse files Browse the repository at this point in the history
  • Loading branch information
jcristau authored Jun 15, 2023
1 parent fdbf2f0 commit fdeb9f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/auslib/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,7 @@ def getRawMatches():
self.log.debug("%s doesn't match %s", rule["version"], updateQuery["version"])
continue
if not matchBuildID(rule["buildID"], updateQuery.get("buildID", "")):
self.log.debug("%s doesn't match %s", rule["buildID"], updateQuery["buildID"])
self.log.debug("%s doesn't match %s", rule["buildID"], updateQuery.get("buildID"))
continue
if not matchMemory(rule["memory"], updateQuery.get("memory")):
self.log.debug("%s doesn't match %s", rule["memory"], updateQuery.get("memory"))
Expand All @@ -1889,7 +1889,7 @@ def getRawMatches():
# specified in a single rule. They are comma delimited, so we need to
# break them out and create clauses for each one.
if not matchSimpleExpression(rule["osVersion"], updateQuery.get("osVersion", "")):
self.log.debug("%s doesn't match %s", rule["osVersion"], updateQuery["osVersion"])
self.log.debug("%s doesn't match %s", rule["osVersion"], updateQuery.get("osVersion"))
continue
if not matchCsv(rule["instructionSet"], updateQuery.get("instructionSet", ""), substring=False):
self.log.debug("%s doesn't match %s", rule["instructionSet"], updateQuery.get("instructionSet"))
Expand Down
11 changes: 11 additions & 0 deletions tests/web/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ def guardian_db(db_schema):
"""
),
)
dbo.rules.t.insert().execute(
priority=150,
backgroundRate=100,
mapping="Guardian-Evil-1.0.0.0",
update_type="minor",
product="Guardian",
channel="release",
osVersion="EvilOS",
data_version=1,
comment="Bogus rule with osVersion set",
)
dbo.rules.t.insert().execute(
priority=150,
backgroundRate=100,
Expand Down

0 comments on commit fdeb9f7

Please sign in to comment.