AlertSuppression: add support for //codeql comments

This commit is contained in:
Arthur Baars
2022-12-14 15:26:29 +01:00
parent c176606be5
commit c9739b21cb
3 changed files with 31 additions and 4 deletions

View File

@@ -12,8 +12,8 @@ import Metrics.Internal.Extents
/** Gets the LGTM suppression annotation text in the string `s`, if any. */
bindingset[s]
string getAnnotationText(string s) {
// match `lgtm[...]` anywhere in the comment
result = s.regexpFind("(?i)\\blgtm\\s*\\[[^\\]]*\\]", _, _)
// match `lgtm[...]` or `codeql[...]` anywhere in the comment
result = s.regexpFind("(?i)\\b(lgtm|codeql)\\s*\\[[^\\]]*\\]", _, _).trim()
}
/**
@@ -96,5 +96,5 @@ where
annotationText = getAnnotationText(text)
select c, // suppression entity
text, // full text of suppression string
annotationText, // LGTM suppression annotation text
annotationText.regexpReplaceAll("(?i)^codeql", "lgtm"), // LGTM suppression annotation text
c.getScope() // scope of suppression