Commit 8be4261a authored by Leo's avatar Leo

refactor(secfixes-check): give better errors in violations

parent c528c1a3
......@@ -135,12 +135,12 @@ local function checkGNUTLS(str, line)
-- Check if we were given just the string 'GNUTLS-SA'
---
if str:len() == 0 then
violation("GNUTLS-SA identifier given is empty", line, "51", "SC")
violation("GNUTLS-SA ID given is empty", line, "51", "SC")
return
end
-- GNUTLS-SA Identifirs are made up of only integers and hyphens after the CVE- prefix
if not str:match("^%-[%d%-]*$") then
violation("GNUTLS-SA identifier given is not composed of only digits and hyphens", line, "51", "SC")
violation("GNUTLS-SA ID given is not composed of only digits and hyphens", line, "51", "SC")
end
-- GNUTLS-SA Identifiers' first field is made of the the year in 4 digits YYYY
if not str:match("^%-%d%d%d%d") then
......@@ -152,23 +152,22 @@ local function checkGNUTLS(str, line)
else
-- Extract the month
local month = tonumber(str:sub(7, 8))
---
-- Check if we have the substring in our set of months, if not then the
-- user gave us an invalid month
---
-- Check if we have a valid month
if (month < 1 or month > 12) then
violation("GNUTLS-SA ID has invalid month, it must be between 01 and 12", line, "51", "SC")
end
end
---
-- Match the starting hyphen, then anything until the next hyphen, then everything until the
-- next hyphen, then try to match 2 integers, they should be the day, if lower than 10 then
-- it should have a leading 0
---
if not str:match("^%-.-%-.-%-%d%d$") then
violation("GNUTLS-SA ID given has a bad day, it needs to be in DD format", line, "51", "SC")
else
-- Extract the day
local day = tonumber(str:sub(10, 11))
---
-- Check if we have the substring in our set of days, if not then the
-- user gave us an invalid day
---
-- Check if we have a valid day
if (day < 1 or day > 31) then
violation("GNUTLS-SA ID given has a bad day, it needs to be between 01 and 31", line, "51", "SC")
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment