Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
atools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leo
atools
Commits
c528c1a3
Commit
c528c1a3
authored
Apr 03, 2020
by
Leo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(secfixes-check): use integer comparison for days and months
parent
d892a86d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
62 deletions
+5
-62
secfixes-check
secfixes-check
+5
-62
No files found.
secfixes-check
View file @
c528c1a3
#!/usr/bin/lua5.3
local function has(set, neddle)
for _, v in ipairs(set) do
if v == neddle then
return true
end
end
return false
end
local function violation(str, line, tag, sevcer)
if os.getenv('SKIP_AL'..tag) then
return
...
...
@@ -138,55 +129,6 @@ end
--- Check the GNUTLS identifier for validy
local function checkGNUTLS(str, line)
local days = {
"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"28",
"29",
"30",
"31"
}
local months = {
"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
"11",
"12"
}
str = str:gsub("^GNUTLS%-SA", "")
---
...
...
@@ -194,6 +136,7 @@ local function checkGNUTLS(str, line)
---
if str:len() == 0 then
violation("GNUTLS-SA identifier 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
...
...
@@ -208,12 +151,12 @@ local function checkGNUTLS(str, line)
violation("GNUTLS-SA ID given has a bad month, it needs to be in MM format", line, "51", "SC")
else
-- Extract the month
local
substr = str:sub(7, 8
)
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
---
if
not has(months, substr
) then
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
...
...
@@ -221,12 +164,12 @@ local function checkGNUTLS(str, line)
violation("GNUTLS-SA ID given has a bad day, it needs to be in DD format", line, "51", "SC")
else
-- Extract the day
local
substr = str:sub(10, 11
)
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
---
if
not has(days, substr
) then
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
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment