Reduce FPs in IncorrectPrivilegeAssignment.ql

Implements suggestions from https://github.com/github/codeql/pull/6949#issuecomment-976482965
This commit is contained in:
Jaroslav Lobačevski
2022-01-18 13:43:17 +01:00
committed by GitHub
parent be0c26f83d
commit 92f5a5f893

View File

@@ -53,7 +53,13 @@ where
fctmp.getTarget().hasGlobalOrStdName("fopen") or
fctmp.getTarget().hasGlobalOrStdName("open")
) and
not fctmp.getArgument(1).getValue().matches("r%") and
(
fctmp.getArgument(1).getValue().matches("%a%") or
// unfortunately cannot use numeric value here because // O_APPEND is defined differently on different OSes:
// https://github.com/red/red/blob/92feb0c0d5f91e087ab35fface6906afbf99b603/runtime/definitions.reds#L477-L491
// this may introduce false negatives
fctmp.getArgument(1).getValueText().matches("%O_APPEND%")
) and
fctmp.getNumberOfArguments() = 2 and
not fctmp.getArgument(0).getValue() = "/dev/null" and
fcsnd = fctmp