Skip to content

Conversation

@aphralG
Copy link
Contributor

@aphralG aphralG commented Oct 3, 2025

Proposed changes

Added syslog server port option in agent config

syslog_server:
    port: 1514

Default value is 1514, agent will parse the NGINX config for Nap syslog server directives, when one is found agent will check if the host is valid and then check if the port matches the configured syslog server port in the config (or default if not set)
If the agent fails to find a valid syslog server it will log the following warning, which contains the configured port

level=WARN msg="Could not find available local NGINX App Protect syslog server configured on port 565. Security violations will not be collected."

Changed NapSyslogServers in NginxConfigContext to a single value as we no longer allow multiple syslog servers.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • I have run make install-tools and have attached any dependency changes to this pull request
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • If applicable, I have updated any relevant documentation (README.md)
  • If applicable, I have tested my cross-platform changes on Ubuntu 22, Redhat 8, SUSE 15 and FreeBSD 13

@aphralG aphralG self-assigned this Oct 3, 2025
@aphralG aphralG requested a review from a team as a code owner October 3, 2025 12:39
@github-actions github-actions bot added the chore Pull requests for routine tasks label Oct 3, 2025
napSyslogServersMap := make(map[string]bool)
for _, server := range napSyslogServers {
napSyslogServersMap[server] = true
func (oc *Collector) findAvailableSyslogServers(ctx context.Context, napSyslogServer string) string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (oc *Collector) findAvailableSyslogServers(ctx context.Context, napSyslogServer string) string {
func (oc *Collector) findAvailableSyslogServer(ctx context.Context, napSyslogServer string) string {

fs.String(
SyslogServerPort,
DefSyslogServerPort,
"The port Agent will start the syslog server for Nginx App Protect Security violations on",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"The port Agent will start the syslog server for Nginx App Protect Security violations on",
"The port Agent will start the syslog server on for logs collection",

@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 95.45455% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.99%. Comparing base (383ce95) to head (2300301).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
internal/collector/otel_collector_plugin.go 88.23% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1317      +/-   ##
==========================================
+ Coverage   84.88%   84.99%   +0.11%     
==========================================
  Files         100      100              
  Lines       14520    14531      +11     
==========================================
+ Hits        12325    12351      +26     
+ Misses       1734     1717      -17     
- Partials      461      463       +2     
Files with missing lines Coverage Δ
internal/config/config.go 85.70% <100.00%> (+0.13%) ⬆️
internal/config/defaults.go 100.00% <ø> (ø)
internal/config/flags.go 100.00% <ø> (ø)
internal/config/types.go 85.41% <ø> (ø)
internal/datasource/config/nginx_config_parser.go 79.19% <100.00%> (-0.17%) ⬇️
internal/model/config.go 88.67% <100.00%> (ø)
internal/collector/otel_collector_plugin.go 81.91% <88.23%> (-0.25%) ⬇️

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 383ce95...2300301. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Akshay2191 Akshay2191 self-requested a review October 14, 2025 13:27
}

oc.previousNAPSysLogServer = napSyslogServer
slog.InfoContext(ctx, "Found valid NAP syslog server", "address", napSyslogServer)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove this info message and have it in the config parser instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a log message already in the parser that it found one. I had this on as the config parser could find a NAP server but when the otel plugin goes to use it the port is unavailable but I can remove it if its causing problems

} else if napEnabled {
slog.WarnContext(ctx, "Could not find available local NGINX App Protect syslog server. "+
"Security violations will not be collected.")
if napEnabled && nginxConfigContext.NAPSysLogServer == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this if statement outside the for loop so that its not logged multiple times?
also can you can an else statement to log on info message saying that you found a syslog server configured for NAP?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Pull requests for routine tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants