@@ -15,15 +15,15 @@ let sarifResults: Object
1515let cweXml : Document
1616
1717let cweFilePath = resolve ( dirname ( process . argv [ 1 ] ) , '..//security-standards/owasp-top10-2021.xml' )
18- let cweFileXmlNs = { cwe : 'http://cwe.mitre.org/cwe-6' }
18+ const cweFileXmlNs = { cwe : 'http://cwe.mitre.org/cwe-6' }
1919let cweIdXpath = '/cwe:Weakness_Catalog/cwe:Weaknesses/cwe:Weakness/@ID'
2020let categoryXpath = '/cwe:Weakness_Catalog/cwe:Categories/cwe:Category[contains(@Name, "OWASP Top Ten 2021")]'
21- let categoryMembersXpath = 'cwe:Relationships/cwe:Has_Member/@CWE_ID'
22- let categoryNameAttr = '@Name'
23- let categoryNameReplaceSearch = 'OWASP Top Ten 2021 Category '
24- let codeQlCweTagPrefix = 'external/cwe/cwe-'
21+ const categoryMembersXpath = 'cwe:Relationships/cwe:Has_Member/@CWE_ID'
22+ const categoryNameAttr = '@Name'
23+ const categoryNameReplaceSearch = 'OWASP Top Ten 2021 Category '
24+ const codeQlCweTagPrefix = 'external/cwe/cwe-'
2525let securityStandardTag = 'owasp-top10-2021'
26- let codeQlTagsJsonPath = '$.runs[*].tool.extensions[*].rules[*].properties.tags'
26+ const codeQlTagsJsonPath = '$.runs[*].tool.extensions[*].rules[*].properties.tags'
2727
2828// Parse Actions or CLI inputs
2929if ( env . GITHUB_ACTIONS === 'true' ) {
@@ -74,11 +74,11 @@ try {
7474}
7575const select = xpath . useNamespaces ( cweFileXmlNs )
7676const cweIds = ( select ( cweIdXpath , cweXml ) as Attr [ ] ) . map ( attribute => attribute . value )
77- const cweCategoryNodes = ( select ( categoryXpath , cweXml ) as Node [ ] )
78- let cweCategories : { [ k : string ] : string [ ] } = { }
77+ const cweCategoryNodes = select ( categoryXpath , cweXml ) as Node [ ]
78+ const cweCategories : { [ k : string ] : string [ ] } = { }
7979for ( const cweCategoryNode of cweCategoryNodes ) {
80- let memberCweIds = ( select ( categoryMembersXpath , cweCategoryNode ) as Attr [ ] ) . map ( attr => attr . value )
81- let categoryName = ( select ( categoryNameAttr , cweCategoryNode , true ) as Attr ) . value . replace ( categoryNameReplaceSearch , '' )
80+ const memberCweIds = ( select ( categoryMembersXpath , cweCategoryNode ) as Attr [ ] ) . map ( attr => attr . value )
81+ const categoryName = ( select ( categoryNameAttr , cweCategoryNode , true ) as Attr ) . value . replace ( categoryNameReplaceSearch , '' )
8282 for ( const cweId of memberCweIds ) {
8383 cweCategories [ cweId ] = [ ...( cweCategories [ cweId ] || [ ] ) , categoryName ]
8484 }
0 commit comments