Skip to content

Commit 5733c09

Browse files
committed
parser-cov: accept http:// and https:// URLs as path
1 parent 97ea941 commit 5733c09

File tree

6 files changed

+235
-1
lines changed

6 files changed

+235
-1
lines changed

src/lib/parser-common.hh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
#define RE_CHECKER_NAME_MISRA "(?:MISRA C(?:\\+\\+)?-[0-9]+ (?:Directive|Rule) [0-9.-]+)"
3030
#define RE_CHECKER_NAME RE_CHECKER_NAME_SA "|" RE_CHECKER_NAME_CERT "|" RE_CHECKER_NAME_MISRA
3131

32+
#define RE_PATH_LOCAL "[^:]+"
33+
#define RE_PATH_URL "http(?:s)?://[^:]+(?::[0-9]+)?[^:]+"
34+
#define RE_PATH RE_PATH_LOCAL "|" RE_PATH_URL
35+
3236
#define RE_EVENT_GCC "(?:(?:(?:fatal|internal) )?[A-Za-z][A-Za-z0-9_-]+)(?:\\[[^ \\]]+\\])?"
3337
#define RE_EVENT_PROSPECTOR "(?:[A-Z]+[0-9]+\\[[a-z0-9-]+\\])"
3438
#define RE_EVENT RE_EVENT_GCC "|" RE_EVENT_PROSPECTOR

src/lib/parser-cov.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class ErrFileLexer {
151151
RE("^Error: *(" RE_CHECKER_NAME ")( *\\([^)]+\\))? *:(?: \\[#def[0-9]+\\])?$");
152152

153153
const RE reEvent_ =
154-
RE(/* location */ "^([^:]+)(?::([0-9]+|<[Uu]nknown>))?(?::([0-9]+))?"
154+
RE(/* location */ "^(" RE_PATH ")(?::([0-9]+|<[Uu]nknown>))?(?::([0-9]+))?"
155155
/* evt/mesg */ ": (" RE_EVENT "): (.*)$");
156156
};
157157

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--mode=json --set-scan-prop=analyzer-version-zap:2.11.1
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Error: OWASP_ZAP_WARNING (CWE-200):
2+
http://rhos-fedora-devel.usersys.redhat.com:5000: note: dynamically analyzed on Tue, 9 Aug 2022 14:38:31
3+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id: alert[90022]: Application Error Disclosure
4+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id: desc: <p>This page contains an error/warning message that may disclose sensitive information like the location of the file that produced the unhandled exception. This information can be used to launch further attacks against the web application. The alert could be a false positive if the error message is found inside a documentation page.</p>
5+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id: solution: <p>Review the source code of this page. Implement custom error pages. Consider implementing a mechanism to provide a unique error reference/identifier to the client (browser) while logging the details on the server side and not exposing them to the user.</p>
6+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id: method: GET
7+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id: evidence: HTTP/1.1 500 INTERNAL SERVER ERROR
8+
9+
Error: OWASP_ZAP_WARNING (CWE-200):
10+
http://rhos-fedora-devel.usersys.redhat.com:5000: note: dynamically analyzed on Tue, 9 Aug 2022 14:38:31
11+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id: alert[10023]: Information Disclosure - Debug Error Messages
12+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id: desc: <p>The response appeared to contain common error messages returned by platforms such as ASP.NET, and Web-servers such as IIS and Apache. You can configure the list of common debug messages.</p>
13+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id: solution: <p>Disable debugging messages before pushing to production.</p>
14+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id: method: GET
15+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id: evidence: Internal Server Error
16+
17+
Error: OWASP_ZAP_WARNING (CWE-693):
18+
http://rhos-fedora-devel.usersys.redhat.com:5000: note: dynamically analyzed on Tue, 9 Aug 2022 14:38:31
19+
http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json: alert[10021]: X-Content-Type-Options Header Missing
20+
http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json: desc: <p>The Anti-MIME-Sniffing header X-Content-Type-Options was not set to 'nosniff'. This allows older versions of Internet Explorer and Chrome to perform MIME-sniffing on the response body, potentially causing the response body to be interpreted and displayed as a content type other than the declared content type. Current (early 2014) and legacy versions of Firefox will use the declared content type (if one is set), rather than performing MIME-sniffing.</p>
21+
http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json: solution: <p>Ensure that the application/web server sets the Content-Type header appropriately, and that it sets the X-Content-Type-Options header to 'nosniff' for all web pages.</p><p>If possible, ensure that the end user uses a standards-compliant and modern web browser that does not perform MIME-sniffing at all, or that can be directed by the web application/web server to not perform MIME-sniffing.</p>
22+
http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json: otherinfo: <p>This issue still applies to error type pages (401, 403, 500, etc.) as those pages are often still affected by injection issues, in which case there is still concern for browsers sniffing pages away from their actual content type.</p><p>At "High" threshold this scan rule will not alert on client or server error responses.</p>
23+
http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json: reference: <p>http://msdn.microsoft.com/en-us/library/ie/gg622941%28v=vs.85%29.aspx</p><p>https://owasp.org/www-community/Security_Headers</p>
24+
http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json: method: GET
25+
http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json: param: X-Content-Type-Options
26+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/: method: GET
27+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/: param: X-Content-Type-Options
28+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/name/pet_name: method: GET
29+
http://rhos-fedora-devel.usersys.redhat.com:5000/pets/name/pet_name: param: X-Content-Type-Options
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
{
2+
"scan": {
3+
"analyzer-version-zap": "2.11.1"
4+
},
5+
"defects": [
6+
{
7+
"checker": "OWASP_ZAP_WARNING",
8+
"cwe": 200,
9+
"tool": "owasp-zap",
10+
"key_event_idx": 5,
11+
"events": [
12+
{
13+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000",
14+
"line": 0,
15+
"event": "note",
16+
"message": "dynamically analyzed on Tue, 9 Aug 2022 14:38:31",
17+
"verbosity_level": 1
18+
},
19+
{
20+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id",
21+
"line": 0,
22+
"event": "alert[90022]",
23+
"message": "Application Error Disclosure",
24+
"verbosity_level": 1
25+
},
26+
{
27+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id",
28+
"line": 0,
29+
"event": "desc",
30+
"message": "<p>This page contains an error/warning message that may disclose sensitive information like the location of the file that produced the unhandled exception. This information can be used to launch further attacks against the web application. The alert could be a false positive if the error message is found inside a documentation page.</p>",
31+
"verbosity_level": 1
32+
},
33+
{
34+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id",
35+
"line": 0,
36+
"event": "solution",
37+
"message": "<p>Review the source code of this page. Implement custom error pages. Consider implementing a mechanism to provide a unique error reference/identifier to the client (browser) while logging the details on the server side and not exposing them to the user.</p>",
38+
"verbosity_level": 1
39+
},
40+
{
41+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id",
42+
"line": 0,
43+
"event": "method",
44+
"message": "GET",
45+
"verbosity_level": 1
46+
},
47+
{
48+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id",
49+
"line": 0,
50+
"event": "evidence",
51+
"message": "HTTP/1.1 500 INTERNAL SERVER ERROR",
52+
"verbosity_level": 0
53+
}
54+
]
55+
},
56+
{
57+
"checker": "OWASP_ZAP_WARNING",
58+
"cwe": 200,
59+
"tool": "owasp-zap",
60+
"key_event_idx": 5,
61+
"events": [
62+
{
63+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000",
64+
"line": 0,
65+
"event": "note",
66+
"message": "dynamically analyzed on Tue, 9 Aug 2022 14:38:31",
67+
"verbosity_level": 1
68+
},
69+
{
70+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id",
71+
"line": 0,
72+
"event": "alert[10023]",
73+
"message": "Information Disclosure - Debug Error Messages",
74+
"verbosity_level": 1
75+
},
76+
{
77+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id",
78+
"line": 0,
79+
"event": "desc",
80+
"message": "<p>The response appeared to contain common error messages returned by platforms such as ASP.NET, and Web-servers such as IIS and Apache. You can configure the list of common debug messages.</p>",
81+
"verbosity_level": 1
82+
},
83+
{
84+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id",
85+
"line": 0,
86+
"event": "solution",
87+
"message": "<p>Disable debugging messages before pushing to production.</p>",
88+
"verbosity_level": 1
89+
},
90+
{
91+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id",
92+
"line": 0,
93+
"event": "method",
94+
"message": "GET",
95+
"verbosity_level": 1
96+
},
97+
{
98+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/id/pet_id",
99+
"line": 0,
100+
"event": "evidence",
101+
"message": "Internal Server Error",
102+
"verbosity_level": 0
103+
}
104+
]
105+
},
106+
{
107+
"checker": "OWASP_ZAP_WARNING",
108+
"cwe": 693,
109+
"tool": "owasp-zap",
110+
"key_event_idx": 11,
111+
"events": [
112+
{
113+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000",
114+
"line": 0,
115+
"event": "note",
116+
"message": "dynamically analyzed on Tue, 9 Aug 2022 14:38:31",
117+
"verbosity_level": 1
118+
},
119+
{
120+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json",
121+
"line": 0,
122+
"event": "alert[10021]",
123+
"message": "X-Content-Type-Options Header Missing",
124+
"verbosity_level": 1
125+
},
126+
{
127+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json",
128+
"line": 0,
129+
"event": "desc",
130+
"message": "<p>The Anti-MIME-Sniffing header X-Content-Type-Options was not set to 'nosniff'. This allows older versions of Internet Explorer and Chrome to perform MIME-sniffing on the response body, potentially causing the response body to be interpreted and displayed as a content type other than the declared content type. Current (early 2014) and legacy versions of Firefox will use the declared content type (if one is set), rather than performing MIME-sniffing.</p>",
131+
"verbosity_level": 1
132+
},
133+
{
134+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json",
135+
"line": 0,
136+
"event": "solution",
137+
"message": "<p>Ensure that the application/web server sets the Content-Type header appropriately, and that it sets the X-Content-Type-Options header to 'nosniff' for all web pages.</p><p>If possible, ensure that the end user uses a standards-compliant and modern web browser that does not perform MIME-sniffing at all, or that can be directed by the web application/web server to not perform MIME-sniffing.</p>",
138+
"verbosity_level": 1
139+
},
140+
{
141+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json",
142+
"line": 0,
143+
"event": "otherinfo",
144+
"message": "<p>This issue still applies to error type pages (401, 403, 500, etc.) as those pages are often still affected by injection issues, in which case there is still concern for browsers sniffing pages away from their actual content type.</p><p>At \"High\" threshold this scan rule will not alert on client or server error responses.</p>",
145+
"verbosity_level": 1
146+
},
147+
{
148+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json",
149+
"line": 0,
150+
"event": "reference",
151+
"message": "<p>http://msdn.microsoft.com/en-us/library/ie/gg622941%28v=vs.85%29.aspx</p><p>https://owasp.org/www-community/Security_Headers</p>",
152+
"verbosity_level": 1
153+
},
154+
{
155+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json",
156+
"line": 0,
157+
"event": "method",
158+
"message": "GET",
159+
"verbosity_level": 1
160+
},
161+
{
162+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/docs/openapi.json",
163+
"line": 0,
164+
"event": "param",
165+
"message": "X-Content-Type-Options",
166+
"verbosity_level": 1
167+
},
168+
{
169+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/",
170+
"line": 0,
171+
"event": "method",
172+
"message": "GET",
173+
"verbosity_level": 1
174+
},
175+
{
176+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/",
177+
"line": 0,
178+
"event": "param",
179+
"message": "X-Content-Type-Options",
180+
"verbosity_level": 1
181+
},
182+
{
183+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/name/pet_name",
184+
"line": 0,
185+
"event": "method",
186+
"message": "GET",
187+
"verbosity_level": 1
188+
},
189+
{
190+
"file_name": "http://rhos-fedora-devel.usersys.redhat.com:5000/pets/name/pet_name",
191+
"line": 0,
192+
"event": "param",
193+
"message": "X-Content-Type-Options",
194+
"verbosity_level": 0
195+
}
196+
]
197+
}
198+
]
199+
}

tests/csgrep/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ test_csgrep("0100-sarif-parser-gitleaks" )
147147
test_csgrep("0101-json-parser-empty" )
148148
test_csgrep("0102-xml-parser-empty" )
149149
test_csgrep("0103-json-parser-zap" )
150+
test_csgrep("0104-cov-parser-zap" )
150151
test_csgrep("0106-snyk-prepend-path" )
151152
test_csgrep("0107-gcc-prepend-path" )
152153
test_csgrep("0108-sarif-empty-results" )

0 commit comments

Comments
 (0)