Skip to content

Sync HTTP Sender API Scan script #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- passive/Report non static sites.js
- passive/RPO.js
- passive/s3.js
- httpsender/Alert on Unexpected Content Types.js now checks for common content-types (`json`, `xml`, and `yaml`) more consistently.

## [18] - 2024-01-29
### Added
Expand Down
22 changes: 7 additions & 15 deletions httpsender/Alert on Unexpected Content Types.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,9 @@ var extensionAlert = control
.getExtensionLoader()
.getExtension(org.zaproxy.zap.extension.alert.ExtensionAlert.NAME);

var expectedTypes = [
"application/health+json",
"application/json",
"application/octet-stream",
"application/problem+json",
"application/problem+xml",
"application/soap+xml",
"application/vnd.api+json",
"application/xml",
"application/x-yaml",
"text/x-json",
"text/json",
"text/yaml",
];
var expectedTypes = ["application/octet-stream", "text/plain"];

var expectedTypeGroups = ["json", "yaml", "xml"];

function sendingRequest(msg, initiator, helper) {
// Nothing to do
Expand All @@ -40,7 +29,10 @@ function responseReceived(msg, initiator, helper) {
if (ctype.indexOf(";") > 0) {
ctype = ctype.substring(0, ctype.indexOf(";"));
}
if (expectedTypes.indexOf(ctype) < 0) {
if (
!msg.getResponseHeader().hasContentType(expectedTypeGroups) &&
expectedTypes.indexOf(ctype) < 0
) {
// Another rule will complain if theres no type

var risk = 1; // Low
Expand Down