Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/permissions/egress.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
// caches it in the inspector's compiledPatterns map for reuse.
func (e *EgressInspector) compilePattern(pattern string) *regexp.Regexp {
if cached, ok := e.compiledPatterns.Load(pattern); ok {
return cached.(*regexp.Regexp)

Check failure on line 86 in internal/permissions/egress.go

View workflow job for this annotation

GitHub Actions / lint

Error return value is not checked (errcheck)
}

regexStr := "^" + regexp.QuoteMeta(pattern) + "$"
Expand All @@ -94,7 +94,7 @@
}

if val, loaded := e.compiledPatterns.LoadOrStore(pattern, re); loaded {
return val.(*regexp.Regexp)

Check failure on line 97 in internal/permissions/egress.go

View workflow job for this annotation

GitHub Actions / lint

Error return value is not checked (errcheck)
}
return re
}
Expand Down Expand Up @@ -405,16 +405,16 @@
return true
}

// Wildcard matching
if strings.Contains(pattern, "*") {
// Wildcard matching
if strings.Contains(pattern, "*") {
// Convert glob pattern to regex with caching
regexStr := "^" + regexp.QuoteMeta(pattern) + "$"
regexStr = strings.ReplaceAll(regexStr, `\*`, `[A-Za-z0-9._-]*`)
re, loaded := cachedRegex.LoadOrStore(regexStr, regexp.MustCompile(regexStr))
if loaded {
return re.(*regexp.Regexp).MatchString(host)

Check failure on line 415 in internal/permissions/egress.go

View workflow job for this annotation

GitHub Actions / lint

Error return value is not checked (errcheck)
}
return re.(*regexp.Regexp).MatchString(host)

Check failure on line 417 in internal/permissions/egress.go

View workflow job for this annotation

GitHub Actions / lint

Error return value is not checked (errcheck)
}

// Subdomain match: pattern "example.com" matches "sub.example.com"
Expand Down
Loading