Skip to content

Commit a9d8794

Browse files
jofJonathan Lassoff
andauthored
Add support for the ipsets section (#22)
* Add support for the ipsets section Addresses #21 * ipsets: Update testdata/ --------- Co-authored-by: Jonathan Lassoff <[email protected]>
1 parent 67803e3 commit a9d8794

File tree

5 files changed

+42
-10
lines changed

5 files changed

+42
-10
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.PHONY: testdata
2+
testdata:
3+
go run . \
4+
-f testdata/input-parent.hujson \
5+
-d testdata/departments/ \
6+
-o testdata/output-file-to-compare-to.hujson \
7+
-allow=acls,grants,groups,ipsets,ssh,tests

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var (
3030
"extraDNSRecords": handleArray(),
3131
"grants": handleArray(),
3232
"groups": handleObject(),
33+
"ipsets": handleObject(),
3334
"nodeAttrs": handleArray(), // TODO: need to merge anything?
3435
"postures": handleObject(),
3536
"ssh": handleArray(),
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ipsets": {
3+
"ipset:finance": ["192.0.2.1"],
4+
},
5+
}

testdata/input-parent.hujson

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,8 @@
6363
"tag:dave": [],
6464
"tag:jane": [],
6565
},
66+
67+
"ipsets": {
68+
"ipset:parent": ["192.0.2.0"],
69+
},
6670
}

testdata/output-file-to-compare-to.hujson

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2+
// from `testdata/input-parent.hujson`
23
"RandomizeClientPort": true, // inline comment
34

45
"acls": [
5-
// from testdata/departments/engineering/acls.hujson
6+
// from `testdata/input-parent.hujson`
67
{
78
// engineering1
89
"action": "accept",
@@ -27,14 +28,14 @@
2728
"dst": ["tag:demo-infra:22"],
2829
"srcPosture": ["posture:latestMac"],
2930
},
30-
// from testdata/departments/engineering/acls.json
31+
// from `testdata/departments/engineering/acls.json`
3132
{
3233
"action": "accept",
3334
"src": ["[email protected]"],
3435
"dst": ["tag:json-rule:22"],
3536
"srcPosture": ["posture:latestMac"],
3637
},
37-
// from testdata/departments/finance/acls.hujson
38+
// from `testdata/departments/finance/acls.hujson`
3839
{
3940
// finance1
4041
"action": "accept",
@@ -51,6 +52,7 @@
5152
},
5253
],
5354

55+
// from `testdata/input-parent.hujson`
5456
"extraDNSRecords": [
5557
{
5658
"Name": "exra.dns.records",
@@ -59,7 +61,7 @@
5961
],
6062

6163
"grants": [
62-
// from testdata/departments/engineering/grants.hujson
64+
// from `testdata/departments/engineering/grants.hujson`
6365
{
6466
//"src": ["group:prod"],
6567
"src": ["[email protected]"],
@@ -70,15 +72,25 @@
7072
],
7173

7274
"groups": {
75+
// from `testdata/input-parent.hujson`
7376
"group:parent": ["from-parent"],
7477

75-
// from testdata/departments/engineering/groups.hujson
78+
// from `testdata/departments/engineering/groups.hujson`
7679
"group:group1": ["[email protected]"],
7780

78-
// from testdata/departments/finance/acls.hujson
81+
// from `testdata/departments/finance/acls.hujson`
7982
"group:group2": ["[email protected]"],
8083
},
8184

85+
"ipsets": {
86+
// from `testdata/input-parent.hujson`
87+
"ipset:parent": ["192.0.2.0"],
88+
89+
// from `testdata/departments/finance/ipsets.hujson`
90+
"ipset:parent": ["192.0.2.1"],
91+
},
92+
93+
// from `testdata/input-parent.hujson`
8294
"nodeAttrs": [
8395
{
8496
"target": ["*"],
@@ -105,23 +117,25 @@
105117
},
106118
],
107119

120+
// from `testdata/input-parent.hujson`
108121
"postures": {"posture:latestMac": ["node:os IN ['macos', 'linux']","node:tsReleaseTrack == 'stable'","node:tsVersion >= '1.40'"]},
109122

110123
"ssh": [
124+
// from `testdata/input-parent.hujson`
111125
{
112126
"action": "accept",
113127
"src": ["autogroup:member"],
114128
"dst": ["autogroup:self"],
115129
"users": ["root", "autogroup:nonroot"],
116130
},
117-
// from testdata/departments/engineering/acls.hujson
131+
// from `testdata/departments/engineering/acls.hujson`
118132
{
119133
"action": "accept",
120134
"src": ["group:finance"],
121135
"dst": ["autogroup:self"],
122136
"users": ["root", "autogroup:nonroot"],
123137
},
124-
// from testdata/departments/finance/ssh.hujson
138+
// from `testdata/departments/finance/ssh.hujson`
125139
{
126140
"action": "accept",
127141
"src": ["autogroup:member"],
@@ -136,6 +150,7 @@
136150
},
137151
],
138152

153+
// from `testdata/input-parent.hujson`
139154
"tagOwners": {
140155
"tag:parent": [],
141156
"tag:cameron": ["autogroup:member"],
@@ -144,12 +159,12 @@
144159
},
145160

146161
"tests": [
147-
// from testdata/departments/engineering/acls.hujson
162+
// from `testdata/input-parent.hujson`
148163
{
149164
150165
"accept": ["tag:cameron:22"],
151166
},
152-
// from testdata/departments/finance/acls.hujson
167+
// from `testdata/departments/finance/acls.hujson`
153168
{
154169
155170
"srcPostureAttrs": {"node:os": "windows"},

0 commit comments

Comments
 (0)