Skip to content

Commit 2d00941

Browse files
authored
Merge pull request #454 from thc202/sync-api-script
2 parents ef073f2 + 0267be5 commit 2d00941

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4242
- passive/Report non static sites.js
4343
- passive/RPO.js
4444
- passive/s3.js
45+
- httpsender/Alert on Unexpected Content Types.js now checks for common content-types (`json`, `xml`, and `yaml`) more consistently.
4546

4647
## [18] - 2024-01-29
4748
### Added

httpsender/Alert on Unexpected Content Types.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,9 @@ var extensionAlert = control
1010
.getExtensionLoader()
1111
.getExtension(org.zaproxy.zap.extension.alert.ExtensionAlert.NAME);
1212

13-
var expectedTypes = [
14-
"application/health+json",
15-
"application/json",
16-
"application/octet-stream",
17-
"application/problem+json",
18-
"application/problem+xml",
19-
"application/soap+xml",
20-
"application/vnd.api+json",
21-
"application/xml",
22-
"application/x-yaml",
23-
"text/x-json",
24-
"text/json",
25-
"text/yaml",
26-
];
13+
var expectedTypes = ["application/octet-stream", "text/plain"];
14+
15+
var expectedTypeGroups = ["json", "yaml", "xml"];
2716

2817
function sendingRequest(msg, initiator, helper) {
2918
// Nothing to do
@@ -40,7 +29,10 @@ function responseReceived(msg, initiator, helper) {
4029
if (ctype.indexOf(";") > 0) {
4130
ctype = ctype.substring(0, ctype.indexOf(";"));
4231
}
43-
if (expectedTypes.indexOf(ctype) < 0) {
32+
if (
33+
!msg.getResponseHeader().hasContentType(expectedTypeGroups) &&
34+
expectedTypes.indexOf(ctype) < 0
35+
) {
4436
// Another rule will complain if theres no type
4537

4638
var risk = 1; // Low

0 commit comments

Comments
 (0)