Skip to content
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

Add cli argument to configure NAP log level #2479

Merged
merged 2 commits into from
Mar 23, 2022

Conversation

galitskiy
Copy link
Contributor

Proposed changes

implement NAP log level configuration via cli argument. Replacing manual preparing of logger configuration file (in Dockerfile and internally when using nginxdebug) with invoking perl tool (installed with app-protect).

Checklist

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

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto master
  • I will ensure my PR is targeting the master branch and pulling from my branch from my own fork

@lucacome lucacome requested review from a team, lucacome, haywoodsh and shaun-nx March 11, 2022 01:51
@lucacome lucacome added the enhancement Pull requests for new features/feature enhancements label Mar 11, 2022
@lucacome
Copy link
Member

@galitskiy looks like there's a security error

@galitskiy
Copy link
Contributor Author

HI @lucacome . not sure ho to avoid this warning... prbl have a harcoded loglevel instead of using variable value directly (smth like if var=x, fullCmd = cmd +x)

@codecov-commenter
Copy link

Codecov Report

Merging #2479 (128bec1) into master (057dfd5) will increase coverage by 0.17%.
The diff coverage is 22.72%.

❗ Current head 128bec1 differs from pull request most recent head c04e002. Consider uploading reports for the commit c04e002 to get more accurate results

@@            Coverage Diff             @@
##           master    #2479      +/-   ##
==========================================
+ Coverage   53.48%   53.66%   +0.17%     
==========================================
  Files          49       48       -1     
  Lines       14306    14228      -78     
==========================================
- Hits         7652     7635      -17     
+ Misses       6411     6352      -59     
+ Partials      243      241       -2     
Impacted Files Coverage Δ
internal/nginx/fake_manager.go 0.00% <0.00%> (ø)
internal/nginx/manager.go 0.00% <0.00%> (ø)
cmd/nginx-ingress/main.go 6.98% <35.71%> (+0.69%) ⬆️
internal/configs/configmaps.go 16.77% <0.00%> (-1.45%) ⬇️
internal/configs/parsing_helpers.go 68.91% <0.00%> (-0.32%) ⬇️
internal/configs/config_params.go 76.74% <0.00%> (ø)
internal/configs/version1/config.go 0.00% <0.00%> (ø)
cmd/nginx-ingress/aws.go
internal/k8s/configuration.go 95.86% <0.00%> (+0.38%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@@ -248,6 +251,17 @@ func main() {
glog.Fatal("NGINX App Protect support is for NGINX Plus only")
}

if *appProtectLogLevel != appProtectLogLevelDefault && !*appProtect && !*nginxPlus {
Copy link
Member

Choose a reason for hiding this comment

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

I know that DOS is implemented the same way, but I find it a bit redundant and I think it also increases the complexity of the code

I feel something like this would be better

if *appProtect {
	if *appProtectLogLevel != appProtectLogLevelDefault {
		...
	}
	// all the other future checks
}

but maybe we can refactor both later. Do you think it adds much value to check those other flags if AP it's not enabled, instead of just ignoring it?

Anyway at this point in the code you also already checked that it's nginxPlus so there's no need to check it again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, frankly speaking there is not much of a value in checking all flags if AP is not enabled. But It also sounds reasonable to me to refactor later in order to have the same approach for AP and DOS.

@lucacome lucacome requested review from ciarams87 and pleshakov March 22, 2022 05:09
@lucacome lucacome changed the title add cli argument to configure NAP log level Add cli argument to configure NAP log level Mar 23, 2022
@lucacome lucacome merged commit b5b4d1f into nginx:master Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Pull requests for new features/feature enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants