Skip to content

Commit e90a249

Browse files
authored
Merge pull request #29 from mildis/master
Rename whitelist to allowlist
2 parents 89f6817 + 88d887d commit e90a249

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The filter currently supports:
1212
- adding an `X-SenderScore` header with the score of the source IP address
1313
- adding an `X-Spam` header to hosts with reputation below a certain value
1414
- applying a time penalty proportional to the IP reputation
15-
- whitelisting IP addresses or subnets
15+
- allowlisting IP addresses or subnets
1616

1717

1818
## Dependencies
@@ -59,4 +59,4 @@ listen on all filter "senderscore"
5959

6060
`-scoreHeader` will add an X-SenderScore header with reputation value if known.
6161

62-
`-whitelist <file>` can be used to specify a file containing a list of IP addresses and subnets in CIDR notation to whitelist, one per line. IP addresses matching any entry in that list automatically receive a score of 100.
62+
`-allowlist <file>` can be used to specify a file containing a list of IP addresses and subnets in CIDR notation to allowlist, one per line. IP addresses matching any entry in that list automatically receive a score of 100.

filter-senderscore.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ var blockPhase *string
3434
var junkBelow *int
3535
var slowFactor *int
3636
var scoreHeader *bool
37-
var whitelistFile *string
37+
var allowlistFile *string
3838
var testMode *bool
39-
var whitelist = make(map[string]bool)
40-
var whitelistMasks = make(map[int]bool)
39+
var allowlist = make(map[string]bool)
40+
var allowlistMasks = make(map[int]bool)
4141

4242
var version string
4343

@@ -95,12 +95,12 @@ func linkConnect(phase string, sessionId string, params []string) {
9595
fmt.Fprintf(os.Stderr, "link-connect addr=%s score=%d\n", addr, s.score)
9696
}(addr, s)
9797

98-
for maskOnes := range whitelistMasks {
98+
for maskOnes := range allowlistMasks {
9999
mask := net.CIDRMask(maskOnes, 32)
100100
maskedAddr := addr.Mask(mask).String()
101101
query := fmt.Sprintf("%s/%d", maskedAddr, maskOnes)
102-
if whitelist[query] {
103-
fmt.Fprintf(os.Stderr, "IP address %s matches whitelisted subnet %s\n", addr, query)
102+
if allowlist[query] {
103+
fmt.Fprintf(os.Stderr, "IP address %s matches allowlisted subnet %s\n", addr, query)
104104
s.score = 100
105105
return
106106
}
@@ -290,12 +290,12 @@ func validatePhase(phase string) {
290290
log.Fatalf("invalid block phase: %s", phase)
291291
}
292292

293-
func loadWhitelists() {
294-
if *whitelistFile == "" {
293+
func loadAllowlists() {
294+
if *allowlistFile == "" {
295295
return
296296
}
297297

298-
file, err := os.Open(*whitelistFile)
298+
file, err := os.Open(*allowlistFile)
299299
if err != nil {
300300
log.Fatal(err)
301301
}
@@ -320,13 +320,13 @@ func loadWhitelists() {
320320
}
321321

322322
maskOnes, _ := subnet.Mask.Size()
323-
if !whitelistMasks[maskOnes] {
324-
whitelistMasks[maskOnes] = true
323+
if !allowlistMasks[maskOnes] {
324+
allowlistMasks[maskOnes] = true
325325
}
326326
subnetStr := subnet.String()
327-
if !whitelist[subnetStr] {
328-
whitelist[subnetStr] = true
329-
fmt.Fprintf(os.Stderr, "Subnet %s added to whitelist\n", subnetStr)
327+
if !allowlist[subnetStr] {
328+
allowlist[subnetStr] = true
329+
fmt.Fprintf(os.Stderr, "Subnet %s added to allowlist\n", subnetStr)
330330
}
331331
}
332332
if err := scanner.Err(); err != nil {
@@ -340,13 +340,13 @@ func main() {
340340
junkBelow = flag.Int("junkBelow", -1, "score below which session is junked")
341341
slowFactor = flag.Int("slowFactor", -1, "delay factor to apply to sessions")
342342
scoreHeader = flag.Bool("scoreHeader", false, "add X-SenderScore header")
343-
whitelistFile = flag.String("whitelist", "", "file containing a list of IP addresses or subnets in CIDR notation to whitelist, one per line")
343+
allowlistFile = flag.String("allowlist", "", "file containing a list of IP addresses or subnets in CIDR notation to allowlist, one per line")
344344
testMode = flag.Bool("testMode", false, "skip all DNS queries, process all requests sequentially, only for debugging purposes")
345345

346346
flag.Parse()
347347

348348
validatePhase(*blockPhase)
349-
loadWhitelists()
349+
loadAllowlists()
350350

351351
scanner := bufio.NewScanner(os.Stdin)
352352
skipConfig(scanner)
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
test_init
66

7-
test_run 'test IP address whitelisting' '
8-
cat <<-EOD >whitelist &&
7+
test_run 'test IP address allowlisting' '
8+
cat <<-EOD >allowlist &&
99
1.1.1.1
1010
3.3.3.3
1111
EOD
12-
cat <<-EOD | "$FILTER_BIN" $FILTER_OPTS -blockBelow 20 -whitelist whitelist | sed "0,/^register|ready/d" >actual &&
12+
cat <<-EOD | "$FILTER_BIN" $FILTER_OPTS -blockBelow 20 -allowlist allowlist | sed "0,/^register|ready/d" >actual &&
1313
config|ready
1414
report|0.5|0|smtp-in|link-connect|7641df9771b4ed00||pass|1.1.1.1:33174|1.1.1.1:25
1515
filter|0.5|0|smtp-in|connect|7641df9771b4ed00|1ef1c203cc576e5d||pass|1.1.1.1:33174|1.1.1.1:25
@@ -26,13 +26,13 @@ test_run 'test IP address whitelisting' '
2626
test_cmp actual expected
2727
'
2828

29-
test_run 'test subnet whitelisting' '
30-
cat <<-EOD >whitelist &&
29+
test_run 'test subnet allowlisting' '
30+
cat <<-EOD >allowlist &&
3131
1.1.0.0/16
3232
1.2.3.0/24
3333
2.0.0.0/8
3434
EOD
35-
cat <<-EOD | "$FILTER_BIN" $FILTER_OPTS -blockBelow 20 -whitelist whitelist | sed "0,/^register|ready/d" >actual &&
35+
cat <<-EOD | "$FILTER_BIN" $FILTER_OPTS -blockBelow 20 -allowlist allowlist | sed "0,/^register|ready/d" >actual &&
3636
config|ready
3737
report|0.5|0|smtp-in|link-connect|7641df9771b4ed00||pass|1.1.1.1:33174|1.1.1.1:25
3838
filter|0.5|0|smtp-in|connect|7641df9771b4ed00|1ef1c203cc576e5d||pass|1.1.1.1:33174|1.1.1.1:25

test/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ check:
33
@./1000-block.sh 2>/dev/null
44
@./2000-junk.sh 2>/dev/null
55
@./3000-headers.sh 2>/dev/null
6-
@./4000-whitelist.sh 2>/dev/null
6+
@./4000-allowlist.sh 2>/dev/null
77
@./9000-legacy.sh 2>/dev/null
88

99
.PHONY: check

0 commit comments

Comments
 (0)