Skip to content

NLB-6875: update R34 Directives #151

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 2 commits into from
Aug 14, 2025
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
34 changes: 18 additions & 16 deletions analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,23 @@ const (
ngxConfTake1234 = ngxConfTake123 | ngxConfTake4

// bit masks for different directive locations.
ngxDirectConf = 0x00010000 // main file (not used)
ngxMgmtMainConf = 0x00020000 // mgmt // unique bitmask that may not match NGINX source
ngxMainConf = 0x00040000 // main context
ngxEventConf = 0x00080000 // events
ngxMailMainConf = 0x00100000 // mail
ngxMailSrvConf = 0x00200000 // mail > server
ngxStreamMainConf = 0x00400000 // stream
ngxStreamSrvConf = 0x00800000 // stream > server
ngxStreamUpsConf = 0x01000000 // stream > upstream
ngxHTTPMainConf = 0x02000000 // http
ngxHTTPSrvConf = 0x04000000 // http > server
ngxHTTPLocConf = 0x08000000 // http > location
ngxHTTPUpsConf = 0x10000000 // http > upstream
ngxHTTPSifConf = 0x20000000 // http > server > if
ngxHTTPLifConf = 0x40000000 // http > location > if
ngxHTTPLmtConf = 0x80000000 // http > location > limit_except
ngxDirectConf = 0x000010000 // main file (not used)
ngxMgmtMainConf = 0x000020000 // mgmt // unique bitmask that may not match NGINX source
ngxMainConf = 0x000040000 // main context
ngxEventConf = 0x000080000 // events
ngxMailMainConf = 0x000100000 // mail
ngxMailSrvConf = 0x000200000 // mail > server
ngxStreamMainConf = 0x000400000 // stream
ngxStreamSrvConf = 0x000800000 // stream > server
ngxStreamUpsConf = 0x001000000 // stream > upstream
ngxHTTPMainConf = 0x002000000 // http
ngxHTTPSrvConf = 0x004000000 // http > server
ngxHTTPLocConf = 0x008000000 // http > location
ngxHTTPUpsConf = 0x010000000 // http > upstream
ngxHTTPSifConf = 0x020000000 // http > server > if
ngxHTTPLifConf = 0x040000000 // http > location > if
ngxHTTPLmtConf = 0x080000000 // http > location > limit_except
ngxHTTPOIDCConf = 0x100000000 // http > oidc_provider
)

// helpful directive location alias describing "any" context
Expand Down Expand Up @@ -126,6 +127,7 @@ var contexts = map[string]uint{
blockCtx{"http", "location", "if"}.key(): ngxHTTPLifConf,
blockCtx{"http", "location", "limit_except"}.key(): ngxHTTPLmtConf,
blockCtx{"mgmt"}.key(): ngxMgmtMainConf,
blockCtx{"http", "oidc_provider"}.key(): ngxHTTPOIDCConf,
}

func enterBlockCtx(stmt *Directive, ctx blockCtx) blockCtx {
Expand Down
24 changes: 12 additions & 12 deletions analyze_nplus_R34_directives.gen.go

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

33 changes: 18 additions & 15 deletions analyze_nplus_latest_directives.gen.go

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

36 changes: 36 additions & 0 deletions analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2894,6 +2894,42 @@ func TestAnalyze_oidc(t *testing.T) {
blockCtx{"stream"},
true,
},
"client_id args not ok": {
&Directive{
Directive: "client_id",
Args: []string{},
Line: 5,
},
blockCtx{"http", "oidc_provider"},
true,
},
"client_id args ok": {
&Directive{
Directive: "client_id",
Args: []string{"unique_id"},
Line: 5,
},
blockCtx{"http", "oidc_provider"},
false,
},
"client_id context not ok": {
&Directive{
Directive: "client_id",
Args: []string{"unique_id"},
Line: 5,
},
blockCtx{"http"},
true,
},
"client_id context ok": {
&Directive{
Directive: "client_id",
Args: []string{"unique_id"},
Line: 5,
},
blockCtx{"http", "oidc_provider"},
false,
},
}

for name, tc := range testcases {
Expand Down
17 changes: 14 additions & 3 deletions scripts/generate/configs/nplus_R34_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
["ngxMailMainConf", "ngxMailSrvConf", "ngxConfTake1"],
["ngxMgmtMainConf", "ngxConfTake1"],
["ngxStreamMainConf", "ngxStreamSrvConf", "ngxConfTake1"],
["ngxConfTake1"]
["ngxHTTPOIDCConf", "ngxConfTake1"]
],
"ssl_name": [["ngxMgmtMainConf", "ngxConfTake1"]],
"ssl_password_file": [
Expand All @@ -107,7 +107,7 @@
["ngxMailMainConf", "ngxMailSrvConf", "ngxConfTake1"],
["ngxMgmtMainConf", "ngxConfTake1"],
["ngxStreamMainConf", "ngxStreamSrvConf", "ngxConfTake1"],
["ngxConfTake1"]
["ngxHTTPOIDCConf", "ngxConfTake1"]
],
"ssl_verify": [["ngxMgmtMainConf", "ngxConfFlag"]],
"ssl_verify_depth": [
Expand All @@ -127,7 +127,18 @@
["ngxMgmtMainConf","ngxConfTake1"]
],
"proxy_username": [["ngxMgmtMainConf","ngxConfTake1"]],
"proxy_password": [["ngxMgmtMainConf","ngxConfTake1"]]
"proxy_password": [["ngxMgmtMainConf","ngxConfTake1"]],
"client_id": [["ngxHTTPOIDCConf", "ngxConfTake1"]],
"client_secret": [["ngxHTTPOIDCConf", "ngxConfTake1"]],
"issuer": [["ngxHTTPOIDCConf", "ngxConfTake1"]],
"config_url": [["ngxHTTPOIDCConf", "ngxConfTake1"]],
"cookie_name": [["ngxHTTPOIDCConf", "ngxConfTake1"]],
"extra_auth_args": [["ngxHTTPOIDCConf", "ngxConfTake1"]],
"redirect_uri": [["ngxHTTPOIDCConf", "ngxConfTake1"]],
"scope": [["ngxHTTPOIDCConf", "ngxConfTake1"]],
"session_store": [["ngxHTTPOIDCConf", "ngxConfTake1"]],
"session_timeout": [["ngxHTTPOIDCConf", "ngxConfTake1"]]

},

"matchFuncComment":"MatchNginxPlusR34 contains directives in Nginx Plus R34 source code(including GEOIP, Perl, and XSLT)"
Expand Down
Loading