-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang][analyzer] Add new option to specify functions SecuritySyntaxChecker warns about
#164184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -839,79 +839,89 @@ def PaddingChecker : Checker<"Padding">, | |
|
|
||
| let ParentPackage = InsecureAPI in { | ||
|
|
||
| def SecuritySyntaxChecker : Checker<"SecuritySyntaxChecker">, | ||
| HelpText<"Base of various security function related checkers">, | ||
| Documentation<NotDocumented>, | ||
| Hidden; | ||
|
|
||
| def bcmp : Checker<"bcmp">, | ||
| HelpText<"Warn on uses of the 'bcmp' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def bcopy : Checker<"bcopy">, | ||
| HelpText<"Warn on uses of the 'bcopy' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def bzero : Checker<"bzero">, | ||
| HelpText<"Warn on uses of the 'bzero' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def gets : Checker<"gets">, | ||
| HelpText<"Warn on uses of the 'gets' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def getpw : Checker<"getpw">, | ||
| HelpText<"Warn on uses of the 'getpw' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def mktemp : Checker<"mktemp">, | ||
| HelpText<"Warn on uses of the 'mktemp' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def mkstemp : Checker<"mkstemp">, | ||
| HelpText<"Warn when 'mkstemp' is passed fewer than 6 X's in the format " | ||
| "string">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
| def SecuritySyntaxChecker | ||
| : Checker<"SecuritySyntaxChecker">, | ||
| HelpText<"Base of various security function related checkers">, | ||
| CheckerOptions<[CmdLineOption< | ||
| String, "Warn", | ||
| "List of space-separated function name to be warned about. " | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you looked a similar existing option? |
||
| "Defaults to an empty list.", | ||
| "", InAlpha>]>, | ||
| Documentation<NotDocumented>, | ||
| Hidden; | ||
|
Comment on lines
+850
to
+851
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this checker base is hidden, would this option appear in the checker help? |
||
|
|
||
| def bcmp : Checker<"bcmp">, | ||
| HelpText<"Warn on uses of the 'bcmp' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
Comment on lines
+853
to
+856
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we have a more generic way of setting the list of checked functions, would this and the rest of the checkers be obsolete if one would add the |
||
|
|
||
| def bcopy : Checker<"bcopy">, | ||
| HelpText<"Warn on uses of the 'bcopy' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def bzero : Checker<"bzero">, | ||
| HelpText<"Warn on uses of the 'bzero' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def gets : Checker<"gets">, | ||
| HelpText<"Warn on uses of the 'gets' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def getpw : Checker<"getpw">, | ||
| HelpText<"Warn on uses of the 'getpw' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def mktemp : Checker<"mktemp">, | ||
| HelpText<"Warn on uses of the 'mktemp' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def mkstemp | ||
| : Checker<"mkstemp">, | ||
| HelpText<"Warn when 'mkstemp' is passed fewer than 6 X's in the format " | ||
| "string">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def rand : Checker<"rand">, | ||
| HelpText<"Warn on uses of the 'rand', 'random', and related functions">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
| def rand | ||
| : Checker<"rand">, | ||
| HelpText<"Warn on uses of the 'rand', 'random', and related functions">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def strcpy : Checker<"strcpy">, | ||
| HelpText<"Warn on uses of the 'strcpy' and 'strcat' functions">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
| def strcpy : Checker<"strcpy">, | ||
| HelpText<"Warn on uses of the 'strcpy' and 'strcat' functions">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def vfork : Checker<"vfork">, | ||
| HelpText<"Warn on uses of the 'vfork' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
| def vfork : Checker<"vfork">, | ||
| HelpText<"Warn on uses of the 'vfork' function">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def UncheckedReturn : Checker<"UncheckedReturn">, | ||
| HelpText<"Warn on uses of functions whose return values must be always " | ||
| "checked">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
| def UncheckedReturn | ||
| : Checker<"UncheckedReturn">, | ||
| HelpText<"Warn on uses of functions whose return values must be always " | ||
| "checked">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def DeprecatedOrUnsafeBufferHandling : | ||
| Checker<"DeprecatedOrUnsafeBufferHandling">, | ||
| HelpText<"Warn on uses of unsecure or deprecated buffer manipulating " | ||
| "functions">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
| def DeprecatedOrUnsafeBufferHandling | ||
| : Checker<"DeprecatedOrUnsafeBufferHandling">, | ||
| HelpText<"Warn on uses of unsecure or deprecated buffer manipulating " | ||
| "functions">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| def decodeValueOfObjCType : Checker<"decodeValueOfObjCType">, | ||
| HelpText<"Warn on uses of the '-decodeValueOfObjCType:at:' method">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
| def decodeValueOfObjCType | ||
| : Checker<"decodeValueOfObjCType">, | ||
| HelpText<"Warn on uses of the '-decodeValueOfObjCType:at:' method">, | ||
| Dependencies<[SecuritySyntaxChecker]>, | ||
| Documentation<HasDocumentation>; | ||
|
|
||
| } // end "security.insecureAPI" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,6 +121,7 @@ | |
| // CHECK-NEXT: region-store-small-struct-limit = 2 | ||
| // CHECK-NEXT: report-in-main-source-file = false | ||
| // CHECK-NEXT: security.cert.env.InvalidPtr:InvalidatingGetEnv = false | ||
| // CHECK-NEXT: security.insecureAPI.SecuritySyntaxChecker:Warn = "" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's nice that we have a test case for the default value of the option, but I think we should really test the case when we set something custom function name too. Would it find calls to the banned custom function? Currently not tests demonstrate this, making the added code uncovered by tests. |
||
| // CHECK-NEXT: serialize-stats = false | ||
| // CHECK-NEXT: silence-checkers = "" | ||
| // CHECK-NEXT: stable-report-filename = false | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this option is not expressive enough. I'd suggest
BannedFunctionsorDisallowedFunctionsinstead.