Skip to content

Commit

Permalink
fix: uri and request parsing;
Browse files Browse the repository at this point in the history
  • Loading branch information
m.gougam committed Feb 27, 2023
1 parent 51fda8b commit db65ea6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/extensions/nginx-app-protect/monitoring/processor/nap.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const (
cookieCtx = "cookie"
defaultBlockedRespCode = "0"
defaultBlockedRespValue = "Blocked"

spaceCharacter = ' '
paramsSeparator = '?'
uriStartCharacter = '/'
)

// NGINX App Protect Logging Directives
Expand Down Expand Up @@ -104,6 +108,7 @@ var (
clientApplicationVersion,
transportProtocol,
httpURI,
request,
}
)

Expand Down Expand Up @@ -450,11 +455,6 @@ func parseNAP(logEntry string, logger *logrus.Entry) (*NAPConfig, error) {
}
}

err := setValue(&waf, request, strings.Join(values[len(logFormatKeys):], ","), logger)
if err != nil {
return &NAPConfig{}, err
}

return &waf, nil
}

Expand Down Expand Up @@ -506,13 +506,13 @@ func setValue(napConfig *NAPConfig, key, value string, logger *logrus.Entry) err
case httpServerPort:
napConfig.HTTPServerPort = value
case httpURI:
napConfig.HTTPURI = value
napConfig.HTTPURI = strings.ReplaceAll(value, "%2C", ",")
case isTruncated:
napConfig.IsTruncated = value
case policyName:
napConfig.PolicyName = value
case request:
napConfig.Request = value
napConfig.Request = strings.ReplaceAll(value, "%2C", ",")
case requestOutcome:
napConfig.RequestOutcome = value
case requestOutcomeReason:
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/nap_monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewNAPMonitoring(env core.Environment, cfg *config.Config) (*NAPMonitoring,
log.Warnf("NAP Monitoring report count must be between %v and %v. Defaulting to %v",
minReportCountDelimiter,
maxReportCountDelimiter,
config.Defaults.NAPMonitoring.ReportInterval)
config.Defaults.NAPMonitoring.ReportCount)
cfg.NAPMonitoring.ReportCount = config.Defaults.NAPMonitoring.ReportCount
}

Expand Down

0 comments on commit db65ea6

Please sign in to comment.