Skip to content

Commit

Permalink
add NAP into go generate
Browse files Browse the repository at this point in the history
  • Loading branch information
dengsh12 committed Aug 1, 2024
1 parent 1d9d21d commit 787a2e7
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 102 deletions.
12 changes: 12 additions & 0 deletions analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

package crossplane

// Upgrade for .gen.go files. If you don't have access to some private modules,
// please use -skip options to skip them. e.g. go generate -skip="nap".

// Update for headersmore
//go:generate sh -c "sh ./scripts/generate/generate.sh --url https://github.com/openresty/headers-more-nginx-module.git --config-path ./scripts/generate/configs/headersmore_config.json > ./analyze_headersMore_directives.gen.go"

Expand All @@ -26,6 +29,15 @@ package crossplane
// Otel provides its own config handler for some directives and they don't have context. Currently we don't support them.
//go:generate sh -c "sh ./scripts/generate/generate.sh --url https://github.com/nginxinc/nginx-otel.git --config-path ./scripts/generate/configs/otel_config.json --branch main > ./analyze_otel_directives.gen.go"

// Update for NAP v4 and v5.
// NAP is a private module. Please ensure you have correct access and put the url.
// and branch of it in environment variable NAP_URL, NAP_V4_BRANCH, and NAP_V5_BRANCH.
// Override is for flag dirctives. NAP used ngxConfTake1 for flag directives, we change them to ngxConfFlag in crossplane.
// NAP v4
//go:generate sh -c "sh ./scripts/generate/generate.sh --url $NAP_URL --config-path ./scripts/generate/configs/nap_v4_config.json --branch $NAP_V4_BRANCH --path ./src > analyze_appProtectWAFv4_directives.gen.go"
// NAP v5
//go:generate sh -c "sh ./scripts/generate/generate.sh --url $NAP_URL --config-path ./scripts/generate/configs/nap_v5_config.json --branch $NAP_V5_BRANCH --path ./src > analyze_appProtectWAFv5_directives.gen.go"

import (
"fmt"
)
Expand Down
88 changes: 88 additions & 0 deletions analyze_appProtectWAFv4_directives.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 0 additions & 51 deletions analyze_appProtectWAFv4_directives.go

This file was deleted.

88 changes: 88 additions & 0 deletions analyze_appProtectWAFv5_directives.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 0 additions & 51 deletions analyze_appProtectWAFv5_directives.go

This file was deleted.

9 changes: 9 additions & 0 deletions scripts/generate/configs/nap_v4_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"directiveMapName":"appProtectWAFv4Directives",
"matchFuncName":"MatchAppProtectWAFv4",
"matchFuncComment":"MatchAppProtectWAFv4 is a MatchFunc for App Protect v4 module.",
"override":{
"app_protect_enable":[["ngxHTTPMainConf", "ngxHTTPSrvConf" , "ngxHTTPLocConf", "ngxConfFlag"]],
"app_protect_security_log_enable":[["ngxHTTPMainConf", "ngxHTTPSrvConf", "ngxHTTPLocConf", "ngxConfFlag"]]
}
}
9 changes: 9 additions & 0 deletions scripts/generate/configs/nap_v5_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"directiveMapName":"appProtectWAFv5Directives",
"matchFuncName":"MatchAppProtectWAFv5",
"matchFuncComment":"MatchAppProtectWAFv5 is a MatchFunc for App Protect v5 module.",
"override":{
"app_protect_enable":[["ngxHTTPMainConf", "ngxHTTPSrvConf" , "ngxHTTPLocConf", "ngxConfFlag"]],
"app_protect_security_log_enable":[["ngxHTTPMainConf", "ngxHTTPSrvConf", "ngxHTTPLocConf", "ngxConfFlag"]]
}
}

0 comments on commit 787a2e7

Please sign in to comment.