Skip to content

Commit b154fd2

Browse files
committed
Add force wildcard resource flag #22
1 parent 7c18d2f commit b154fd2

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ You can optionally also include the following arguments to the `iamlive` command
4646

4747
**--background:** when set, the process will return the current PID and run in the background without output (_default: false_)
4848

49+
**--force-wildcard-resource:** when set, the Resource will always be a wildcard (_default: false_)
50+
4951
**--mode:** _[experimental]_ the listening mode (`csm`,`proxy`) (_default: csm_)
5052

5153
**--bind-addr:** _[experimental]_ the bind address for proxy mode (_default: 127.0.0.1:10080_)
@@ -77,7 +79,7 @@ iamlive --set-ini --profile myprofile --fails-only --output-file policy.json --r
7779
_Comprehensive Example (Proxy Mode)_
7880

7981
```
80-
iamlive --set-ini --mode proxy --profile myprofile --output-file policy.json --refresh-rate 1 --sort-alphabetical --bind-addr 127.0.0.1:10080 --ca-bundle ~/.iamlive/ca.pem --ca-key ~/.iamlive/ca.key --account-id 123456789012 --background
82+
iamlive --set-ini --mode proxy --profile myprofile --output-file policy.json --refresh-rate 1 --sort-alphabetical --bind-addr 127.0.0.1:10080 --ca-bundle ~/.iamlive/ca.pem --ca-key ~/.iamlive/ca.key --account-id 123456789012 --background --force-wildcard-resource
8183
```
8284

8385
The arguments may also be specified in an INI file located at `~/.iamlive/config`.

logger.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ func getPolicyDocument() []byte {
111111
policy.Statement = append(policy.Statement, getStatementsForProxyCall(entry)...)
112112
}
113113

114+
if *forceWildcardResourceFlag {
115+
for i, _ := range policy.Statement {
116+
policy.Statement[i].Resource = []string{"*"}
117+
}
118+
}
119+
114120
policy = aggregatePolicy(policy)
115121

116122
for i := 0; i < len(policy.Statement); i++ { // make any single wildcard resource a non-array

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var caBundleFlag *string
2727
var caKeyFlag *string
2828
var accountIDFlag *string
2929
var backgroundFlag *bool
30+
var forceWildcardResourceFlag *bool
3031
var cpuProfileFlag = flag.String("cpu-profile", "", "[experimental] write a CPU profile to this file (for performance testing purposes)")
3132

3233
func parseConfig() {
@@ -43,6 +44,7 @@ func parseConfig() {
4344
caKey := "~/.iamlive/ca.key"
4445
accountID := "123456789012"
4546
background := false
47+
forceWildcardResource := false
4648

4749
cfgfile, err := homedir.Expand("~/.iamlive/config")
4850
if err == nil {
@@ -87,6 +89,9 @@ func parseConfig() {
8789
if cfg.Section("").HasKey("background") {
8890
background, _ = cfg.Section("").Key("background").Bool()
8991
}
92+
if cfg.Section("").HasKey("force-wildcard-resource") {
93+
forceWildcardResource, _ = cfg.Section("").Key("force-wildcard-resource").Bool()
94+
}
9095
}
9196
}
9297

@@ -103,6 +108,7 @@ func parseConfig() {
103108
caKeyFlag = flag.String("ca-key", caKey, "[experimental] the CA certificate key to use for proxy mode")
104109
accountIDFlag = flag.String("account-id", accountID, "[experimental] the AWS account ID to use in policy outputs within proxy mode")
105110
backgroundFlag = flag.Bool("background", background, "when set, the process will return the current PID and run in the background without output")
111+
forceWildcardResourceFlag = flag.Bool("force-wildcard-resource", forceWildcardResource, "when set, the Resource will always be a wildcard")
106112
}
107113

108114
func main() {

0 commit comments

Comments
 (0)