Skip to content

add secure coding AI review guides#5572

Merged
softhack007 merged 35 commits into
mainfrom
copilot/create-ai-review-guide-wled
May 29, 2026
Merged

add secure coding AI review guides#5572
softhack007 merged 35 commits into
mainfrom
copilot/create-ai-review-guide-wled

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

this PR is adding security-aware review checklists (for coderabbit PR reviews) that should be relevant for WLED.
The lists are based on the OWASP "top 10" from https://github.com/github/awesome-copilot/blob/main/instructions/security-and-owasp.instructions.md, and on lessons learned from past reviews.


This PR now includes:

  • corrected docs filename spelling to match existing docs/*.instructions.md naming pattern:
    • docs/securecode.instructions.md
    • docs/secure-short.instructions.md
  • follow-up adjustments to both guides based on review feedback, including:
    • explicit WLED threat-model assumptions (typical firewall/DMZ/VPN deployment)
    • removal of any mandatory TLS/HTTPS baseline expectation
    • clarification that protocol-defined unauthenticated UDP multicast/broadcast paths should not be flagged solely for lacking auth
    • OTA integrity guidance framed as checksum/hash/signature verification without requiring TLS
    • wording consistency and clarity improvements across both files
  • additional verification against the suggested rule set from issuecomment-4393037994, with missing coverage added to docs/securecode.instructions.md, including concrete pattern guidance for:
    • UDP packet bounds and protocol range clamping
    • explicit JSON parse-error handling patterns
    • OTA integrity checks in Update.* paths
    • FreeRTOS stack/recursion safety checks
    • mDNS/hostname sanitization constraints
    • outbound URL validation (without HTTPS requirement)
    • optional unicast UDP source filtering (advisory)
    • CSRF Origin/Referer advisory checks for non-internet-exposed deployments
    • credential exposure checks in API/config serialization
    • security-event logging coverage
    • workflow action pinning and permission hardening specifics

Summary by CodeRabbit

  • Documentation
    • Added security review guidelines and a 24-rule checklist covering critical security areas including buffer safety, input validation, authentication, secure defaults, and protection against common vulnerabilities.
    • Refined rule wording and priorities to better fit WLED’s technical constraints and realistic deployment model.

Summary by CodeRabbit

  • Documentation

    • Added WLED-focused security and hardening guides: prioritized checklists, low-noise reviewer workflow, AI-review guidance, firmware and Web UI security rules, secrets/logging standards, and CI/CD/supply-chain recommendations.
  • Chores

    • Expanded automated review configuration to cover firmware, Web UI, and usermods; refined trust-boundary and ingress rules and added path-scoped secret-scanning rules with explicit flagging and exemptions.

Review Change Stack

Agent-Logs-Url: https://github.com/wled/WLED/sessions/82b5d757-7791-4aa3-8f77-96b25e52b6d5

Co-authored-by: softhack007 <91616163+softhack007@users.noreply.github.com>
Agent-Logs-Url: https://github.com/wled/WLED/sessions/dc60e89a-6f5e-4441-8b4d-a70d61c1bf5c

Co-authored-by: softhack007 <91616163+softhack007@users.noreply.github.com>
@softhack007 softhack007 changed the title Add WLED secure coding AI review instruction guides WIP (experiment DO NOT MERGE) Add WLED secure coding AI review instruction guides May 6, 2026
@softhack007

This comment was marked as outdated.

@coderabbitai

This comment was marked as outdated.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 81f5d942-c63c-40d1-909e-2b14f746dc9b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

Walkthrough

Adds two WLED security guidance documents (hardening + securecode) and updates .coderabbit.yaml to reference them, applying path-scoped security rules for firmware, WebUI, and usermods plus secrets/supply-chain scanning.

Changes

Security Review Standards and CodeRabbit Configuration

Layer / File(s) Summary
Hardening Rules, Trust-Boundary Model, and Output Format
docs/hardening.instructions.md
Hardening instructions establish WLED threat-boundary ingress model, define CRITICAL and IMPORTANT hardening rules for firmware/WebUI/memory/auth/logging/workflow, and specify standardized reviewer output format requiring severity, exact file/line, and concrete fix direction.
Comprehensive Threat-Model Assumptions and Security Checklists
docs/securecode.instructions.md
Securecode instructions add WLED-specific threat-model constraints and trust-boundary definitions, then provide categorized checklists: FW1–FW14 for firmware memory/validation/auth/OTA/FreeRTOS issues; WEB1–WEB7 for WebUI XSS/dynamic-code/postMessage/navigation; SEC1–SEC6 for secrets/logging; SC1–SC3 for supply-chain/CI; plus consolidated reviewer and AI behavior guidance.
CodeRabbit Path-Scoped Review Rules and Secrets Scanning Configuration
.coderabbit.yaml
Updates references to the new docs, adds path-scoped review rules for firmware (wled00/**/*.{cpp,h,hpp,ino}), WebUI assets (wled00/data/**), and usermods (usermods/**/*.{cpp,h,hpp}), removes an obsolete disabled comment, and introduces secrets/sensitive-info scanning rules and exclusions for templates/placeholders.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • wled/WLED#5480: Both PRs modify .coderabbit.yaml to rework CodeRabbit reviews.path_instructions for firmware/WebUI/usermods; related guidance updates overlap.

Suggested reviewers

  • netmindz
  • DedeHai
  • willmmiles
  • Aircoookie
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title 'add secure coding AI review guides' clearly and accurately summarizes the main change: adding three new documentation files (securecode.instructions.md, hardening.instructions.md) and updating .coderabbit.yaml to configure AI-assisted security review guidance for the WLED project.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added enhancement discussion AI Partly generated by an AI. Make sure that the contributor fully understands the code! labels May 6, 2026
coderabbitai[bot]

This comment was marked as resolved.

Comment thread docs/securecode.instructions.md Outdated
@softhack007

This comment was marked as resolved.

@coderabbitai

This comment was marked as outdated.

@softhack007

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

@softhack007

This comment was marked as outdated.

Copilot AI and others added 2 commits May 7, 2026 00:05
Agent-Logs-Url: https://github.com/wled/WLED/sessions/73d38e00-6610-47e7-a7de-4a926fe0cc68

Co-authored-by: softhack007 <91616163+softhack007@users.noreply.github.com>
Agent-Logs-Url: https://github.com/wled/WLED/sessions/73d38e00-6610-47e7-a7de-4a926fe0cc68

Co-authored-by: softhack007 <91616163+softhack007@users.noreply.github.com>

This comment was marked as outdated.

Copilot AI requested a review from softhack007 May 7, 2026 00:06
@coderabbitai

This comment was marked as resolved.

config-derived => ingress-derived
* strlcmp does not exist in the C standard library, nor in POSIX
* Backtick artifacts in .coderabbit.yaml YAML strings
coderabbitai[bot]

This comment was marked as resolved.

Avoid credential-shaped URL examples that possibly retrigger secret scanners.
coderabbitai[bot]

This comment was marked as resolved.

AI asked for clearer wording, so we clarify wording.
@softhack007 softhack007 changed the title add secure coding AI review instruction guides add secure coding AI review guides May 24, 2026
@softhack007 softhack007 removed the AI Partly generated by an AI. Make sure that the contributor fully understands the code! label May 25, 2026
@coderabbitai coderabbitai Bot added the AI Partly generated by an AI. Make sure that the contributor fully understands the code! label May 25, 2026
Rules are applied when source buffer or copy size are derived from untrusted values.
Add guidance for handling trusted internal values in FW1.
@softhack007

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Comment thread docs/securecode.instructions.md
Comment thread docs/securecode.instructions.md Outdated
coderabbitai[bot]

This comment was marked as resolved.

softhack007 and others added 3 commits May 26, 2026 11:40
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Clarify integer overflow considerations in rules - wrap-around might be intended behaviour.
@softhack007
Copy link
Copy Markdown
Member

@coderabbitai please check if you have learnings stored that are now fully covered by the new rules added in this PR.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
REPO="wled/WLED"
BRANCH="copilot/create-ai-review-guide-wled"

echo "=== .coderabbit.yaml ==="
curl -s "https://raw.githubusercontent.com/$REPO/$BRANCH/.coderabbit.yaml"

echo ""
echo "=== docs/securecode.instructions.md (Trust Boundary section only) ==="
curl -s "https://raw.githubusercontent.com/$REPO/$BRANCH/docs/securecode.instructions.md" | grep -A 20 "Trust Boundary"

echo ""
echo "=== .coderabbit.yaml usermods entry ==="
curl -s "https://raw.githubusercontent.com/$REPO/$BRANCH/.coderabbit.yaml" | grep -A 30 "usermods"

echo ""
echo "=== .coderabbit.yaml secrets entry ==="
curl -s "https://raw.githubusercontent.com/$REPO/$BRANCH/.coderabbit.yaml" | grep -A 40 "Secrets"

Length of output: 24575



@softhack007, here is the coverage check. All four learnings added during this PR conversation are now fully (or substantially) covered by the committed files.


Learning Coverage Status

Learning Added when Now encoded in Status
Trust Boundary Model — ingress points, validated = trusted, don't re-flag downstream Untrusted data sources discussion docs/securecode.instructions.md § Trust Boundary Model + .coderabbit.yaml wled00/** block Fully covered — safe to remove
.coderabbit.yaml uses inline strings only (no file: reference) + trust boundary layout Path instructions suggestion Trust boundary content is in .coderabbit.yaml; the "inline strings only" YAML format constraint is NOT in any file ⚠️ Partially covered — trust boundary content is redundant; the format constraint is still useful if you want to keep one learning
Usermods ingress = readFromConfig() / getJsonValue(), flag only downstream misbehaviour Usermods scope clarification .coderabbit.yaml usermods/**/*.{cpp,h,hpp} block (which also now includes onMqttMessage, onEspNowMessage, onUdpPacket) Fully covered — safe to remove
Secrets path instructions for platformio*.ini*, usermods/**/library.json, usermods/**/README.md Secrets scanning suggestion .coderabbit.yaml Secrets section — all three path entries present Fully covered — safe to remove

Recommendation: The three fully-covered learnings (#1, #3, #4) can be deleted — the rules are now authoritative in .coderabbit.yaml and the *.instructions.md files that CodeRabbit reads per-review. Keeping them creates a risk of stale duplication if the files are later updated.

You can remove them via the CodeRabbit learnings page. Unfortunately I cannot retrieve the learning IDs from this conversation thread (they were stored in hidden HTML comments), but you can identify them by the content descriptions in the table above.

🐰 ✨

@softhack007 softhack007 merged commit 58bf4c8 into main May 29, 2026
31 checks passed
softhack007 added a commit that referenced this pull request May 29, 2026
Added security review guidelines and a short checklist covering critical security areas including buffer safety, input validation, authentication, secure defaults, and protection against common vulnerabilities. Refined rule wording and priorities to better fit WLED’s technical constraints and realistic deployment model.

The lists are based on the OWASP "top 10" from https://github.com/github/awesome-copilot/blob/main/instructions/security-and-owasp.instructions.md, and on lessons learned from past reviews.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: softhack007 <91616163+softhack007@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Partly generated by an AI. Make sure that the contributor fully understands the code! discussion enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants