Skip to content

Commit 73e4245

Browse files
author
Sakshis
committed
modified world-writable-file-cpp
1 parent e653726 commit 73e4245

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

rules/cpp/security/world-writable-file-cpp.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,20 @@ utils:
8787
all:
8888
- has:
8989
kind: binary_expression
90-
has:
91-
kind: identifier
92-
regex: ^(S_IWOTH|S_IWUSR|S_IGRP|S_IROTH|S_IRUSR|S_IWOTH)$
90+
all:
91+
- has:
92+
kind: binary_expression
93+
all:
94+
- has:
95+
kind: identifier
96+
- has:
97+
kind: identifier
98+
- has:
99+
kind: identifier
100+
regex: ^(S_IWOTH|S_IWUSR|S_IGRP|S_IROTH|S_IRUSR|S_IWOTH)$
93101
- has:
94102
kind: identifier
95-
regex: ^(S_IWOTH|S_IWUSR|S_IGRP|S_IRUSR|S_IWOTH)$
96-
inside:
97-
stopBy: end
98-
kind: call_expression
99-
has:
100-
kind: identifier
101-
regex: (chmod|fchmod|fchmodat|open|openat)
102-
inside:
103-
kind: expression_statement
103+
regex: ^(S_IWOTH|S_IWUSR|S_IGRP|S_IROTH|S_IRUSR|S_IWOTH)$
104104
match_binary_with_identifier:
105105
kind: identifier
106106
regex: "^S_IWOTH$"
@@ -158,7 +158,6 @@ utils:
158158
regex: ^(openat)$
159159
inside:
160160
kind: expression_statement
161-
162161
rule:
163162
any:
164163
- matches: match_identifier_with_stringliteral_mode

tests/__snapshots__/world-writable-file-cpp-snapshot.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ snapshots:
7777
style: primary
7878
start: 50
7979
end: 107
80+
- source: S_IWGRP
81+
style: secondary
82+
start: 80
83+
end: 87
84+
- source: S_IWGRP
85+
style: secondary
86+
start: 80
87+
end: 87
88+
- source: S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
89+
style: secondary
90+
start: 50
91+
end: 87
8092
- source: S_IROTH
8193
style: secondary
8294
start: 90
@@ -89,15 +101,3 @@ snapshots:
89101
style: secondary
90102
start: 100
91103
end: 107
92-
- source: chmod("/tmp/foo", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
93-
style: secondary
94-
start: 32
95-
end: 109
96-
- source: chmod
97-
style: secondary
98-
start: 32
99-
end: 37
100-
- source: chmod("/tmp/foo", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
101-
style: secondary
102-
start: 32
103-
end: 108

0 commit comments

Comments
 (0)