-
Notifications
You must be signed in to change notification settings - Fork 11
/
rule-allow.go
35 lines (27 loc) · 979 Bytes
/
rule-allow.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package rule
import (
"github.com/airbnb/rudolph/internal/cli/flags"
"github.com/airbnb/rudolph/pkg/clock"
"github.com/airbnb/rudolph/pkg/dynamodb"
"github.com/airbnb/rudolph/pkg/types"
"github.com/spf13/cobra"
)
func init() {
tf := flags.TargetFlags{}
rf := flags.RuleInfoFlags{}
var ruleAllowCmd = &cobra.Command{
Use: "allow [-f <file-path>|-i <identifier/sha256>] -t <rule-type> [-m <machine-id>|--global]",
Short: "Create a rule that applies the Allowlist policy to the specified file",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
region, _ := cmd.Flags().GetString("region")
table, _ := cmd.Flags().GetString("dynamodb_table")
dynamodbClient := dynamodb.GetClient(table, region)
time := clock.ConcreteTimeProvider{}
return applyPolicyForPath(time, dynamodbClient, types.Allowlist, tf, rf)
},
}
tf.AddTargetFlags(ruleAllowCmd)
rf.AddRuleInfoFlags(ruleAllowCmd)
RuleCmd.AddCommand(ruleAllowCmd)
}