Documentation
¶
Overview ¶
Package azureaccess asks Azure Resource Manager whether the credentials in the environment can read a subscription, and which actions they hold on it.
The first question is asked by two callers: `draugr doctor`, to say whether a declared subscription can be reached, and the prowler scanner, before Prowler runs. The second is the scanner's. Prowler's Azure service base class discards the exceptions its worker threads raise, so a denial inside a service can leave no log line, and the answer has to come from somewhere other than its output.
Prowler has no flag for Azure's whole default credential chain: each of its flags keeps one credential and excludes the others. AuthFlag chooses the flag, and New builds the credential that flag leaves Prowler with, which is what makes the answer about the scan rather than about this process.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoCredentials = errors.New("no usable Azure credentials found: run `az login`, set " +
"AZURE_CLIENT_ID, AZURE_TENANT_ID and AZURE_CLIENT_SECRET, or run where a managed identity is attached")
ErrNoCredentials is a machine with no Azure credential that yields a token.
var ErrRefused = errors.New("the credentials may not list their permissions on the subscription")
ErrRefused is a permissions question Azure refused to answer for these credentials.
Functions ¶
func AuthFlag ¶
AuthFlag is the Prowler flag for the credential the environment declares.
A service principal's three variables are the only form --sp-env-auth accepts, and Prowler refuses to start with one missing. IDENTITY_ENDPOINT is what App Service, Functions, Container Apps and Arc set for a managed identity. Everything else is --az-cli-auth, which leaves Prowler the sign-in `az login` holds, a federated one and `az login --identity` included, and workload identity where AZURE_FEDERATED_TOKEN_FILE is set. A virtual machine's managed identity sets no variable, so it is reached with `az login --identity`.
func Denied ¶
func Denied(grants []Permission, actions []string) []string
Denied returns the actions, in the order given, that none of the grants allow. Deny assignments are outside the answer Azure gives, and Prowler's log catches those.
func HoldsAnAction ¶
func HoldsAnAction(grants []Permission) bool
HoldsAnAction reports whether any grant allows anything. Azure answers an empty list for credentials with no role on a subscription they can still see.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client asks Azure Resource Manager with one credential.
func New ¶
New builds the credential AuthFlag selects from the environment and returns a Client that asks with it.
func (*Client) Permissions ¶
Permissions lists the credentials' grants on the subscription, every page of them.
func (*Client) Subscription ¶
Subscription asks for the subscription, which needs Microsoft.Resources/subscriptions/read.
A subscription the credentials hold no role on and one that does not exist are one answer here, because neither says which: the error says both.
type Permission ¶
type Permission struct {
// Actions are the action patterns the role allows.
Actions []string `json:"actions"`
// NotActions are the patterns excluded from this entry's Actions. They take nothing away from
// another entry.
NotActions []string `json:"notActions"`
// DataActions are the data-plane patterns the role allows, which the checks' control-plane reads do
// not use.
DataActions []string `json:"dataActions"`
}
Permission is one role's grant on a subscription, as Microsoft.Authorization/permissions returns it. An action is held when one entry's Actions match it and that entry's NotActions do not.
type Reader ¶
type Reader interface {
// Subscription returns the subscription, or an error naming it when the credentials cannot read it.
Subscription(ctx context.Context, id string) (Subscription, error)
// Permissions lists the credentials' grants on the subscription. ErrRefused says they may not ask.
Permissions(ctx context.Context, id string) ([]Permission, error)
}
Reader asks Azure Resource Manager about a subscription.
type Subscription ¶
type Subscription struct {
// ID is the subscription's GUID.
ID string
// Name is its display name.
Name string
}
Subscription is what Azure says about a subscription the credentials can read.