Skip to content

Commit 8944baa

Browse files
authored
For PAR config settings, declare using strings not const (#53767)
### What does this PR do? Cleanup how privateactionrunner declares settings: use literal strings for each setting name, instead of a constant. ### Motivation Two primary reasons: 1) Make it easier for the code analyzer to find these settings, and 2) make an easier codegen target. ### Describe how you validated your changes Built the agent + CI ### Additional Notes Running the codegen via `dda inv schema.codegen` is dependent on [`a020191` (#53765)](a020191) in order to work correctly. Co-authored-by: dustin.long <dustin.long@datadoghq.com>
1 parent 88442ec commit 8944baa

2 files changed

Lines changed: 43 additions & 24 deletions

File tree

pkg/config/schema/yaml/private_action_runner.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ properties:
1818
visibility: public
1919
description: Set to true to enable the Private Action Runner.
2020
example: 'true'
21+
comment: Enable/disable private action runner
2122
self_enroll:
2223
node_type: setting
2324
type: boolean
@@ -28,12 +29,14 @@ properties:
2829
Requires an app_key with Actions API Enable and the following permissions:
2930
- Connection Write
3031
- Private Action Write
32+
comment: Identity / enrollment configuration
3133
task_concurrency:
3234
node_type: setting
3335
type: integer
3436
default: 5
3537
visibility: public
3638
description: Maximum number of actions that can be executed concurrently.
39+
comment: General config
3740
task_timeout_seconds:
3841
node_type: setting
3942
type: integer
@@ -73,6 +76,7 @@ properties:
7376
visibility: public
7477
description: Maximum time in seconds for HTTP actions before timing out. Must
7578
be > 1.
79+
comment: HTTP action
7680
http_allowlist:
7781
node_type: setting
7882
type: array
@@ -118,6 +122,7 @@ properties:
118122
node_type: setting
119123
type: string
120124
default: ${log_path}/private-action-runner.log
125+
comment: Log file
121126
opms_extra_headers:
122127
node_type: setting
123128
type: object
@@ -146,6 +151,20 @@ properties:
146151
- /
147152
items:
148153
type: string
154+
comment: |-
155+
Restricted shell allow-lists are opt-in restrictions layered on top of
156+
the backend-injected lists. By default, they act as a no-op, allowing
157+
everything: the backend is the only filter.
158+
159+
To allow none, use an explicit empty list.
160+
Env vars support both CSV and JSON-array forms; the JSON form gives
161+
env/YAML parity, including the explicit kill-switch via "[]".
162+
163+
- allowed_paths defaults to ["/"].
164+
- allowed_commands defaults to ["rshell:*"]. The wildcard token is
165+
handled as a special case in the operator-side intersection: when
166+
it appears in the operator list, every backend command in the
167+
"rshell:" namespace is admitted.
149168
skip_connection_creation:
150169
node_type: setting
151170
type: boolean

pkg/config/setup/privateactionrunner_settings.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ import (
1313
// setupPrivateActionRunner registers all configuration keys for the private action runner
1414
func setupPrivateActionRunner(config pkgconfigmodel.Setup) {
1515
// Enable/disable private action runner
16-
config.BindEnvAndSetDefault(PAREnabled, false)
16+
config.BindEnvAndSetDefault("private_action_runner.enabled", false)
1717

1818
// Log file
19-
config.BindEnvAndSetDefault(PARLogFile, "${log_path}/private-action-runner.log")
19+
config.BindEnvAndSetDefault("private_action_runner.log_file", "${log_path}/private-action-runner.log")
2020

2121
// Identity / enrollment configuration
22-
config.BindEnvAndSetDefault(PARSelfEnroll, true)
23-
config.BindEnvAndSetDefault(PARApiKeyOnlyEnrollment, false)
24-
config.BindEnvAndSetDefault(PARIdentityFilePath, "")
25-
config.BindEnvAndSetDefault(PARIdentityUseK8sSecret, true)
26-
config.BindEnvAndSetDefault(PARIdentitySecretName, "private-action-runner-identity")
27-
config.BindEnvAndSetDefault(PARPrivateKey, "")
28-
config.BindEnvAndSetDefault(PARUrn, "")
29-
config.BindEnvAndSetDefault(PARSkipConnectionCreation, false)
22+
config.BindEnvAndSetDefault("private_action_runner.self_enroll", true)
23+
config.BindEnvAndSetDefault("private_action_runner.api_key_only_enrollment", false)
24+
config.BindEnvAndSetDefault("private_action_runner.identity_file_path", "")
25+
config.BindEnvAndSetDefault("private_action_runner.identity_use_k8s_secret", true)
26+
config.BindEnvAndSetDefault("private_action_runner.identity_secret_name", "private-action-runner-identity")
27+
config.BindEnvAndSetDefault("private_action_runner.private_key", "")
28+
config.BindEnvAndSetDefault("private_action_runner.urn", "")
29+
config.BindEnvAndSetDefault("private_action_runner.skip_connection_creation", false)
3030

3131
// General config
32-
config.BindEnvAndSetDefault(PARTaskConcurrency, 5)
33-
config.BindEnvAndSetDefault(PARTaskTimeoutSeconds, 60)
34-
config.BindEnvAndSetDefault(PARActionsAllowlist, []string{})
35-
config.BindEnvAndSetDefault(PARDefaultActionsEnabled, true)
36-
config.ParseEnvSplitComma(PARActionsAllowlist)
32+
config.BindEnvAndSetDefault("private_action_runner.task_concurrency", 5)
33+
config.BindEnvAndSetDefault("private_action_runner.task_timeout_seconds", 60)
34+
config.BindEnvAndSetDefault("private_action_runner.actions_allowlist", []string{})
35+
config.BindEnvAndSetDefault("private_action_runner.default_actions_enabled", true)
36+
config.ParseEnvSplitComma("private_action_runner.actions_allowlist")
3737

3838
// Executor mode (split deployment)
3939
config.BindEnvAndSetDefault(PARExecutorSocketPath, GetPlatformDefault(map[string]interface{}{
@@ -42,10 +42,10 @@ func setupPrivateActionRunner(config pkgconfigmodel.Setup) {
4242
}))
4343

4444
// HTTP action
45-
config.BindEnvAndSetDefault(PARHttpTimeoutSeconds, 30)
46-
config.BindEnvAndSetDefault(PARHttpAllowlist, []string{})
47-
config.ParseEnvSplitComma(PARHttpAllowlist)
48-
config.BindEnvAndSetDefault(PARHttpAllowImdsEndpoint, false)
45+
config.BindEnvAndSetDefault("private_action_runner.http_timeout_seconds", 30)
46+
config.BindEnvAndSetDefault("private_action_runner.http_allowlist", []string{})
47+
config.ParseEnvSplitComma("private_action_runner.http_allowlist")
48+
config.BindEnvAndSetDefault("private_action_runner.http_allow_imds_endpoint", false)
4949

5050
// Restricted shell allow-lists are opt-in restrictions layered on top of
5151
// the backend-injected lists. By default, they act as a no-op, allowing
@@ -60,11 +60,11 @@ func setupPrivateActionRunner(config pkgconfigmodel.Setup) {
6060
// handled as a special case in the operator-side intersection: when
6161
// it appears in the operator list, every backend command in the
6262
// "rshell:" namespace is admitted.
63-
config.BindEnvAndSetDefault(PARRestrictedShellAllowedPaths, []string{RShellPathAllowAll})
64-
pkgconfighelper.ParseEnvJSONOrComma(PARRestrictedShellAllowedPaths, config)
63+
config.BindEnvAndSetDefault("private_action_runner.restricted_shell.allowed_paths", []string{RShellPathAllowAll})
64+
pkgconfighelper.ParseEnvJSONOrComma("private_action_runner.restricted_shell.allowed_paths", config)
6565

66-
config.BindEnvAndSetDefault(PARRestrictedShellAllowedCommands, []string{RShellCommandAllowAllWildcard})
67-
pkgconfighelper.ParseEnvJSONOrComma(PARRestrictedShellAllowedCommands, config)
66+
config.BindEnvAndSetDefault("private_action_runner.restricted_shell.allowed_commands", []string{RShellCommandAllowAllWildcard})
67+
pkgconfighelper.ParseEnvJSONOrComma("private_action_runner.restricted_shell.allowed_commands", config)
6868

69-
config.BindEnvAndSetDefault(PAROpmsExtraHeaders, map[string]string{})
69+
config.BindEnvAndSetDefault("private_action_runner.opms_extra_headers", map[string]string{})
7070
}

0 commit comments

Comments
 (0)