Skip to content

Commit

Permalink
Fix code scanning alert no. 4: Incomplete regular expression for host…
Browse files Browse the repository at this point in the history
…names (#726)

* Fix code scanning alert no. 4: Incomplete regular expression for hostnames

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix security issues in regex

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
jocgir and github-advanced-security[bot] authored Nov 27, 2024
1 parent f44b2b5 commit c07f64b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions awshelper/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ func formatS3Path(bucket, region string, parts ...string) string {
func GetBucketObjectInfoFromURL(url string) (*BucketInfo, error) {
if s3Patterns == nil {
s3Patterns = []*regexp.Regexp{
regexp.MustCompile(`^https?://(?P<bucket>[^/\.]+?).s3.amazonaws.com(?:/(?P<key>.*))?$`),
regexp.MustCompile(`^https?://(?P<bucket>[^/\.]+?).s3-(?P<region>.*?).amazonaws.com(?:/(?P<key>.*))?$`),
regexp.MustCompile(`^(s3::)?https?://s3.amazonaws.com/(?P<bucket>[^/\.]+?)(?:/(?P<key>.*))?$`),
regexp.MustCompile(`^(s3::)?https?://s3-(?P<region>.*?).amazonaws.com/(?P<bucket>[^/\.]+?)(?:/(?P<key>.*))?$`),
regexp.MustCompile(`^https?://(?P<bucket>[^/\.]+?)\.s3\.amazonaws\.com(?:/(?P<key>.*))?$`),
regexp.MustCompile(`^https?://(?P<bucket>[^/\.]+?)\.s3-(?P<region>.*?)\.amazonaws\.com(?:/(?P<key>.*))?$`),
regexp.MustCompile(`^(s3::)?https?://s3\.amazonaws\.com/(?P<bucket>[^/\.]+?)(?:/(?P<key>.*))?$`),
regexp.MustCompile(`^(s3::)?https?://s3-(?P<region>.*?)\.amazonaws\.com/(?P<bucket>[^/\.]+?)(?:/(?P<key>.*))?$`),
}
}

Expand Down

0 comments on commit c07f64b

Please sign in to comment.