Skip to content

Check for unquoted YAML strings#829

Open
fmarier wants to merge 3 commits intomainfrom
unquoted-strings-yaml
Open

Check for unquoted YAML strings#829
fmarier wants to merge 3 commits intomainfrom
unquoted-strings-yaml

Conversation

@fmarier
Copy link
Copy Markdown
Member

@fmarier fmarier commented Jul 31, 2025

@fmarier fmarier self-assigned this Jul 31, 2025
@fmarier fmarier requested a review from a team as a code owner July 31, 2025 22:58
server:
port: 8080
host: "localhost"
region: us-west
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

# This should trigger the rule (unquoted strings)

config:
name: production
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog


config:
name: production
type: database
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

config:
name: production
type: database
environment: staging
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

@@ -0,0 +1,33 @@
rules:
- id: yaml-unquoted-string
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

assets/semgrep_rules/services/yaml-unquoted-strings.yaml|31| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|33| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|35| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|37| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|38| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|39| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|4| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|40| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|42| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|44| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|45| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|46| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|47| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|48| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|49| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|5| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|51| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|6| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|8| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|9| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

environment: staging

server:
port: 8080
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog


server:
port: 8080
host: "localhost"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

region: us-west

# Test array items
languages:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog


# Test array items
languages:
- yaml
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

# Test array items
languages:
- yaml
- json
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

- pattern: |
- $VALUE
- metavariable-regex:
metavariable: $VALUE
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

- $VALUE
- metavariable-regex:
metavariable: $VALUE
regex: '^[a-zA-Z][a-zA-Z0-9_.-]*$'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

- metavariable-regex:
metavariable: $VALUE
regex: '^[a-zA-Z][a-zA-Z0-9_.-]*$'
- pattern-not: |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

regex: '^[a-zA-Z][a-zA-Z0-9_.-]*$'
- pattern-not: |
- "$VALUE"
- pattern-not: |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

@@ -0,0 +1,51 @@
rules:
- id: yaml-unquoted-string
patterns:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

Added test cases to verify that strings with spaces, hyphens, and underscores
should not be flagged as requiring quotes, while version strings like 1.2.3
and 802.11.x should be flagged.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

assets/semgrep_rules/services/yaml-unquoted-strings.yaml|8| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog
assets/semgrep_rules/services/yaml-unquoted-strings.yaml|9| [semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

# Additional test cases for modified rule

# These should NOT trigger the rule (should not require quotes):
new_config:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog


# These should NOT trigger the rule (should not require quotes):
new_config:
phrase: rule-of-thumb # has hyphen - should not match
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

# These should NOT trigger the rule (should not require quotes):
new_config:
phrase: rule-of-thumb # has hyphen - should not match
description: Alice and bob # has spaces - should not match
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

new_config:
phrase: rule-of-thumb # has hyphen - should not match
description: Alice and bob # has spaces - should not match
float_version: 1.0 # simple numeric - should not match
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

phrase: rule-of-thumb # has hyphen - should not match
description: Alice and bob # has spaces - should not match
float_version: 1.0 # simple numeric - should not match
setting_name: some_value # has underscore - should not match
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

impact: "LOW"
confidence: "MEDIUM"
license: "MPL-2.0"
source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

confidence: "MEDIUM"
license: "MPL-2.0"
source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml
languages:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

- id: yaml-unquoted-string
patterns:
- pattern-either:
- patterns:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml
languages:
- "yaml"
severity: "INFO"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

patterns:
- pattern-either:
- patterns:
- pattern: |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Found unquoted string value in YAML file. Consider quoting string values to avoid parsing ambiguity.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/yaml-unquoted-string.yaml


Cc @thypon @kdenhartog

@thypon thypon force-pushed the main branch 4 times, most recently from c9cb82f to df38488 Compare September 24, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants