Skip to content

Commit 92f5a5f

Browse files
authored
Reduce FPs in IncorrectPrivilegeAssignment.ql
Implements suggestions from #6949 (comment)
1 parent be0c26f commit 92f5a5f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cpp/ql/src/experimental/Security/CWE/CWE-266/IncorrectPrivilegeAssignment.ql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ where
5353
fctmp.getTarget().hasGlobalOrStdName("fopen") or
5454
fctmp.getTarget().hasGlobalOrStdName("open")
5555
) and
56-
not fctmp.getArgument(1).getValue().matches("r%") and
56+
(
57+
fctmp.getArgument(1).getValue().matches("%a%") or
58+
// unfortunately cannot use numeric value here because // O_APPEND is defined differently on different OSes:
59+
// https://github.com/red/red/blob/92feb0c0d5f91e087ab35fface6906afbf99b603/runtime/definitions.reds#L477-L491
60+
// this may introduce false negatives
61+
fctmp.getArgument(1).getValueText().matches("%O_APPEND%")
62+
) and
5763
fctmp.getNumberOfArguments() = 2 and
5864
not fctmp.getArgument(0).getValue() = "/dev/null" and
5965
fcsnd = fctmp

0 commit comments

Comments
 (0)