Skip to content

Commit

Permalink
Merge pull request stripe#185 from stripe/sergeyrud-make-hostMatchesG…
Browse files Browse the repository at this point in the history
…lob-exportable

Make hostMatchesGlob exportable
  • Loading branch information
sergeyrud-stripe authored Feb 22, 2023
2 parents 4835f35 + abacfd9 commit 0c66af9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pkg/smokescreen/acl/v1/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,23 @@ func (acl *ACL) Decide(service, host string) (Decision, error) {

// if the host matches any of the rule's allowed domains, allow
for _, dg := range rule.DomainGlobs {
if hostMatchesGlob(host, dg) {
if HostMatchesGlob(host, dg) {
d.Result, d.Reason = Allow, "host matched allowed domain in rule"
return d, nil
}
}

// if the host matches any of the global deny list, deny
for _, dg := range acl.GlobalDenyList {
if hostMatchesGlob(host, dg) {
if HostMatchesGlob(host, dg) {
d.Result, d.Reason = Deny, "host matched rule in global deny list"
return d, nil
}
}

// if the host matches any of the global allow list, allow
for _, dg := range acl.GlobalAllowList {
if hostMatchesGlob(host, dg) {
if HostMatchesGlob(host, dg) {
d.Result, d.Reason = Allow, "host matched rule in global allow list"
return d, nil
}
Expand Down Expand Up @@ -241,11 +241,11 @@ func (acl *ACL) Rule(service string) *Rule {
return acl.DefaultRule
}

// hostMatchesGlob matches a hostname string against a domain glob after
// HostMatchesGlob matches a hostname string against a domain glob after
// converting both to a canonical form (lowercase with trailing dots removed).
//
// domainGlob should already have been passed through ACL.Validate().
func hostMatchesGlob(host string, domainGlob string) bool {
func HostMatchesGlob(host string, domainGlob string) bool {
if host == "" {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/smokescreen/acl/v1/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func TestHostMatchesGlob(t *testing.T) {
t.Run(name, func(t *testing.T) {
a.Equal(
g.match,
hostMatchesGlob(g.hostname, g.glob),
HostMatchesGlob(g.hostname, g.glob),
)
})
}
Expand Down

0 comments on commit 0c66af9

Please sign in to comment.