MCPcopy Create free account
hub / github.com/auth0/auth0-cli / buildNetworkACLRule

Function buildNetworkACLRule

internal/cli/network_acl.go:458–526  ·  view source on GitHub ↗

buildNetworkACLRule creates a NetworkACLRule from the provided inputs.

(inputs *ruleInputs)

Source from the content-addressed store, hash-verified

456
457// buildNetworkACLRule creates a NetworkACLRule from the provided inputs.
458func buildNetworkACLRule(inputs *ruleInputs) (*management.NetworkACLRule, error) {
459 rule := &management.NetworkACLRule{
460 Scope: &inputs.Scope,
461 }
462
463 // Set the action.
464 rule.Action = &management.NetworkACLRuleAction{}
465 switch inputs.Action {
466 case "block":
467 rule.Action.Block = auth0.Bool(true)
468 case "allow":
469 rule.Action.Allow = auth0.Bool(true)
470 case "log":
471 rule.Action.Log = auth0.Bool(true)
472 case "redirect":
473 rule.Action.Redirect = auth0.Bool(true)
474 rule.Action.RedirectURI = &inputs.RedirectURI
475 }
476
477 // Build match criteria.
478 match := &management.NetworkACLRuleMatch{}
479 matchProvided := false
480
481 if len(inputs.ASNs) > 0 {
482 match.Asns = inputs.ASNs
483 matchProvided = true
484 }
485 if len(inputs.CountryCodes) > 0 {
486 match.GeoCountryCodes = &inputs.CountryCodes
487 matchProvided = true
488 }
489 if len(inputs.SubdivCodes) > 0 {
490 match.GeoSubdivisionCodes = &inputs.SubdivCodes
491 matchProvided = true
492 }
493 if len(inputs.IPv4CIDRs) > 0 {
494 match.IPv4Cidrs = &inputs.IPv4CIDRs
495 matchProvided = true
496 }
497 if len(inputs.IPv6CIDRs) > 0 {
498 match.IPv6Cidrs = &inputs.IPv6CIDRs
499 matchProvided = true
500 }
501 if len(inputs.JA3) > 0 {
502 match.Ja3Fingerprints = &inputs.JA3
503 matchProvided = true
504 }
505 if len(inputs.JA4) > 0 {
506 match.Ja4Fingerprints = &inputs.JA4
507 matchProvided = true
508 }
509 if len(inputs.UserAgents) > 0 {
510 match.UserAgents = &inputs.UserAgents
511 matchProvided = true
512 }
513
514 if !matchProvided {
515 return nil, fmt.Errorf("at least one match criteria must be provided")

Callers 2

createNetworkACLCmdFunction · 0.85
updateNetworkACLCmdFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected