Potential fix for code scanning alert no. 7: Missing regular expression anchor - #59
Potential fix for code scanning alert no. 7: Missing regular expression anchor#59FortiShield wants to merge 1 commit into
Conversation
…on anchor Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: fortishield <161459699+FortiShield@users.noreply.github.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAnchors and tightens the S3 origin hostname regular expression used when identifying public S3 origins for CloudFront distributions, ensuring the full DomainName strictly matches expected S3 host formats instead of matching substrings within larger hostnames. Flow diagram for tightened S3 origin hostname regex checkflowchart TD
A[distribution.Origins.Items loop] --> B{origin.DomainName exists}
B -->|no| E[skip origin]
B -->|yes| C{"origin.DomainName.match(/^s3(?:[.-].*)?\.amazonaws\.com$/)"}
C -->|no| E
C -->|yes| D{S3OriginConfig present and
OriginAccessIdentity empty and
no OriginAccessControlId}
D -->|no| E
D -->|yes| F[push origin to publicOrigins]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|



Potential fix for https://github.com/khulnasoft/cloudexploit/security/code-scanning/7
Use a fully anchored regex so the whole
origin.DomainNamemust match an expected S3 hostname format, instead of allowing matches in the middle of larger strings.Best fix in this file: replace line 55’s pattern with an anchored one:
/s3(.*)\.amazonaws\.com//^s3(?:[.-].*)?\.amazonaws\.com$/This preserves current behavior of allowing regional/variant S3 hostnames that begin with
s3and end with.amazonaws.com, while preventing arbitrary prefixes/suffixes from being accepted. No new imports or helper methods are needed.Suggested fixes powered by Copilot Autofix. Review carefully before merging.
Summary by Sourcery
Bug Fixes: