Skip to content

Commit 646a730

Browse files
committed
rename config_path to gitleaks config
1 parent 9328408 commit 646a730

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

docs/sources/reference/components/loki/loki.secretfilter.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ You can use the following arguments with `loki.secretfilter`:
4343
| Name | Type | Description | Default | Required |
4444
| ---------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | -------- |
4545
| `forward_to` | `list(LogsReceiver)` | List of receivers to send log entries to. | | yes |
46-
| `config_path` | `string` | Path to a custom Gitleaks TOML config file. If empty, the default Gitleaks config is used. | `""` | no |
46+
| `gitleaks_config` | `string` | Path to a custom Gitleaks TOML config file. If empty, the default Gitleaks config is used. | `""` | no |
4747
| `origin_label` | `string` | Loki label to use for the `secrets_redacted_by_origin` metric. If empty, that metric is not registered. | `""` | no |
4848
| `redact_with` | `string` | Template for the redaction placeholder. Use `$SECRET_NAME` and `$SECRET_HASH`. When set, percentage-based redaction is not used. | `"<REDACTED-SECRET:$SECRET_NAME>"` | no |
4949
| `redact_percent` | `uint` | When `redact_with` is not set: percent of the secret to redact (1–100). Shows leading (100-N)% + `"..."`; 100 = full `"REDACTED"`. 0 or unset defaults to 80. | `80` | no |
5050

51-
The `config_path` argument is the path to a custom [Gitleaks TOML config file][gitleaks-config]. The file supports the standard Gitleaks structure (rules, allowlists, and `[extend]` to extend the default config). If `config_path` is empty, the component uses the default Gitleaks configuration [embedded in the component][embedded-config].
51+
The `gitleaks_config` argument is the path to a custom [Gitleaks TOML config file][gitleaks-config]. The file supports the standard Gitleaks structure (rules, allowlists, and `[extend]` to extend the default config). If `gitleaks_config` is empty, the component uses the default Gitleaks configuration [embedded in the component][embedded-config].
5252

5353
{{< admonition type="note" >}}
54-
The default configuration may change between {{< param "PRODUCT_NAME" >}} versions. For consistent behavior, use an external configuration file via `config_path`.
54+
The default configuration may change between {{< param "PRODUCT_NAME" >}} versions. For consistent behavior, use an external configuration file via `gitleaks_config`.
5555
{{< /admonition >}}
5656

5757
**Redaction behavior:**
@@ -92,7 +92,7 @@ The following fields are exported and can be referenced by other components:
9292

9393
## Example
9494

95-
This example shows how to use `loki.secretfilter` to redact secrets from log lines before forwarding them to a Loki receiver. It uses a custom redaction template with `$SECRET_NAME` and `$SECRET_HASH`. You can instead omit `redact_with` to use percentage-based redaction (default 80% redacted), set `redact_percent` (e.g. `100` for full redaction), or set `config_path` to point to a custom Gitleaks TOML file.
95+
This example shows how to use `loki.secretfilter` to redact secrets from log lines before forwarding them to a Loki receiver. It uses a custom redaction template with `$SECRET_NAME` and `$SECRET_HASH`. You can instead omit `redact_with` to use percentage-based redaction (default 80% redacted), set `redact_percent` (e.g. `100` for full redaction), or set `gitleaks_config` to point to a custom Gitleaks TOML file.
9696

9797
```alloy
9898
local.file_match "local_logs" {
@@ -107,7 +107,7 @@ loki.source.file "local_logs" {
107107
loki.secretfilter "secret_filter" {
108108
forward_to = [loki.write.local_loki.receiver]
109109
redact_with = "<ALLOY-REDACTED-SECRET:$SECRET_NAME:$SECRET_HASH>"
110-
// optional: config_path = "/etc/alloy/gitleaks.toml"
110+
// optional: gitleaks_config = "/etc/alloy/gitleaks.toml"
111111
// optional: redact_percent = 100 // use when redact_with is not set
112112
}
113113

internal/component/loki/secretfilter/secretfilter.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type Arguments struct {
4242
OriginLabel string `alloy:"origin_label,attr,optional"` // The label name to use for tracking metrics by origin (if empty, no origin metrics are collected)
4343
RedactWith string `alloy:"redact_with,attr,optional"` // Template for redaction placeholder; $SECRET_NAME and $SECRET_HASH are replaced. When set, percentage-based redaction is not used.
4444
RedactPercent uint `alloy:"redact_percent,attr,optional"` // When redact_with is not set: percent of the secret to redact (1-100; gitleaks-style: show leading (100-N)% + "...", 100 = "REDACTED"). 0 or unset defaults to 80.
45-
ConfigPath string `alloy:"config_path,attr,optional"` // Path to a gitleaks TOML config file; if empty, the default gitleaks config is used
45+
GitleaksConfig string `alloy:"gitleaks_config,attr,optional"` // Path to a gitleaks TOML config file; if empty, the default gitleaks config is used
4646
}
4747

4848
// Exports holds the values exported by the loki.secretfilter component.
@@ -174,12 +174,12 @@ func loadGitleaksConfig(path string) (config.Config, error) {
174174
}
175175

176176
// newDetectorFromArgs creates a gitleaks detector from component arguments.
177-
// If ConfigPath is empty, the default gitleaks config is used.
177+
// If GitleaksConfig is empty, the default gitleaks config is used.
178178
func newDetectorFromArgs(args Arguments) (*detect.Detector, error) {
179-
if args.ConfigPath == "" {
179+
if args.GitleaksConfig == "" {
180180
return detect.NewDetectorDefaultConfig()
181181
}
182-
cfg, err := loadGitleaksConfig(args.ConfigPath)
182+
cfg, err := loadGitleaksConfig(args.GitleaksConfig)
183183
if err != nil {
184184
return nil, err
185185
}

internal/component/loki/secretfilter/secretfilter_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,22 +251,22 @@ func runTest(t *testing.T, config string, inputLog string, shouldRedact bool) {
251251
wg.Wait()
252252
}
253253

254-
func TestConfigPath_InvalidPath(t *testing.T) {
254+
func TestGitleaksConfig_InvalidPath(t *testing.T) {
255255
opts := component.Options{
256256
Logger: util.TestLogger(t),
257257
OnStateChange: func(e component.Exports) {},
258258
GetServiceData: getServiceData,
259259
}
260260
args := Arguments{
261-
ForwardTo: []loki.LogsReceiver{loki.NewLogsReceiver()},
262-
ConfigPath: filepath.Join(t.TempDir(), "nonexistent.gitleaks.toml"),
261+
ForwardTo: []loki.LogsReceiver{loki.NewLogsReceiver()},
262+
GitleaksConfig: filepath.Join(t.TempDir(), "nonexistent.gitleaks.toml"),
263263
}
264264
_, err := New(opts, args)
265265
require.Error(t, err)
266266
require.Contains(t, err.Error(), "read gitleaks config")
267267
}
268268

269-
func TestConfigPath_ValidFile(t *testing.T) {
269+
func TestGitleaksConfig_ValidFile(t *testing.T) {
270270
dir := t.TempDir()
271271
configPath := filepath.Join(dir, "gitleaks.toml")
272272
require.NoError(t, os.WriteFile(configPath, []byte(minimalGitleaksConfig), 0600))
@@ -279,8 +279,8 @@ func TestConfigPath_ValidFile(t *testing.T) {
279279
Registerer: registry,
280280
}
281281
args := Arguments{
282-
ForwardTo: []loki.LogsReceiver{loki.NewLogsReceiver()},
283-
ConfigPath: configPath,
282+
ForwardTo: []loki.LogsReceiver{loki.NewLogsReceiver()},
283+
GitleaksConfig: configPath,
284284
}
285285
c, err := New(opts, args)
286286
require.NoError(t, err)

0 commit comments

Comments
 (0)