Skip to content

slack: only enforce token prefixes on literal values - #4656

Open
hsdfat wants to merge 1 commit into
redpanda-data:mainfrom
hsdfat:slack-token-lint-interpolation
Open

slack: only enforce token prefixes on literal values#4656
hsdfat wants to merge 1 commit into
redpanda-data:mainfrom
hsdfat:slack-token-lint-interpolation

Conversation

@hsdfat

@hsdfat hsdfat commented Aug 2, 2026

Copy link
Copy Markdown

Fixes #4511.

LintRule(has_prefix("xoxb-")) runs against the raw config value, before interpolation — so a valid bot_token: "${secrets.SLACK_APP_BOT_TOKEN}" was rejected at lint time.

Adds a tokenLintRule(prefix) helper that skips the prefix check when the value is empty or starts with ${, and keeps enforcing it for literals so a malformed literal token is still caught.

The issue reports output_post.go, but the same rule is duplicated in input.go (xapp- and xoxb-), input_users.go, output_reaction.go and processor_thread.go — all five now go through the helper.

A missing required bot_token still produces the separate "field is required" lint, so this doesn't hide a misconfiguration.

Adds lint_test.go covering all five components: unresolved ${secrets...}, an env lookup resolving to empty, valid literal, invalid literal, and a secret whose value starts with the prefix.

The bot_token and app_token fields are linted with a has_prefix check, so
a config that sources the token from a secret, for example

    slack_post:
      bot_token: "${secrets.SLACK_APP_BOT_TOKEN}"

is rejected with "field must start with xoxb-". Secret and environment
variable references are resolved when a config is read, which is not
necessarily before it is linted: a linter without access to the value
sees either the reference verbatim or the empty string it falls back to,
neither of which can be checked against the prefix.

Skip the check for those two cases and keep enforcing it everywhere else,
so a literal token of the wrong type is still reported.

Fixes redpanda-data#4511
@CLAassistant

CLAassistant commented Aug 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minor issue with slack_post component in Redpanda Connect.

2 participants