diff --git a/src/interfaces/analysis-result.interface.ts b/src/interfaces/analysis-result.interface.ts index 3f8cf4e9..f77c1a32 100644 --- a/src/interfaces/analysis-result.interface.ts +++ b/src/interfaces/analysis-result.interface.ts @@ -20,6 +20,7 @@ interface CommitChangeLine { export interface RuleProperties { tags: string[]; + categories: string[]; exampleCommitFixes?: ExampleCommitFix[]; exampleCommitDescriptions?: string[]; precision: string; diff --git a/src/sarif_converter.ts b/src/sarif_converter.ts index 4c258e56..f4f585e4 100644 --- a/src/sarif_converter.ts +++ b/src/sarif_converter.ts @@ -51,9 +51,12 @@ function getSuggestions(analysisResults: IAnalysisResult): ISarifSuggestions { } } return suggestions; -}; +} -function getRulesAndAllIssues(analysisResults: IAnalysisResult, allIssuesBySuggestions: ISarifSuggestions): { rules: ReportingDescriptor[], allIssues: ISarifSuggestion[] } { +function getRulesAndAllIssues( + analysisResults: IAnalysisResult, + allIssuesBySuggestions: ISarifSuggestions, +): { rules: ReportingDescriptor[]; allIssues: ISarifSuggestion[] } { let ruleIndex = 0; const rules: ReportingDescriptor[] = []; const allIssues: ISarifSuggestion[] = []; @@ -67,10 +70,11 @@ function getRulesAndAllIssues(analysisResults: IAnalysisResult, allIssuesBySugge const language = suggestion.id.split('%2F')[0]; const suggestionId = `${language}/${suggestion.rule}`; const ruleProperties: RuleProperties = { - tags: [language, ...suggestion.tags, ...suggestion.categories], + tags: [language, ...suggestion.tags], + categories: suggestion.categories, exampleCommitFixes: suggestion.exampleCommitFixes, exampleCommitDescriptions: suggestion.exampleCommitDescriptions, - precision: 'very-high' + precision: 'very-high', }; const rule = { @@ -86,7 +90,7 @@ function getRulesAndAllIssues(analysisResults: IAnalysisResult, allIssuesBySugge markdown: suggestion.text, text: '', }, - properties: ruleProperties + properties: ruleProperties, }; if (suggestion.cwe?.length) { @@ -106,12 +110,11 @@ function getRulesAndAllIssues(analysisResults: IAnalysisResult, allIssuesBySugge id: suggestionId, text: suggestion.message, }); - }); ruleIndex += 1; } return { rules, allIssues }; -}; +} function getResults(allIssues: ISarifSuggestion[]): Result[] { const output = []; @@ -142,7 +145,7 @@ function getResults(allIssues: ISarifSuggestion[]): Result[] { }, }, }, - ] + ], }; if (issue.fingerprints) { @@ -223,7 +226,7 @@ function getResults(allIssues: ISarifSuggestion[]): Result[] { output.push(newResult); } return output; -}; +} //custom string splice implementation export function stringSplice(str: string, index: number, count: number, add?: string) {