Skip to content

Commit 9721448

Browse files
committed
feat(yamllint): include for this repo and apply rules throughout
* Semi-automated using `ssf-formula` (v0.5.0) * Fix (or ignore) errors shown below: ```bash iptables-formula$ $(grep "\- yamllint" .travis.yml | sed -e "s:^\s\+-\s\(.*\):\1:") ./iptables/defaults.yaml 3:1 warning missing document start "---" (document-start) 50:1 error too many blank lines (1 > 0) (empty-lines) ./iptables/osfamilymap.yaml 3:1 warning missing document start "---" (document-start) ./test/integration/tables/inspec.yml 8:89 error line too long (89 > 88 characters) (line-length) pillar.example 1:1 warning missing document start "---" (document-start) 2:12 warning truthy value should be one of [false, true] (truthy) 3:12 warning truthy value should be one of [false, true] (truthy) 4:11 warning truthy value should be one of [false, true] (truthy) 5:9 warning truthy value should be one of [false, true] (truthy) 8:22 warning truthy value should be one of [false, true] (truthy) 14:22 warning truthy value should be one of [false, true] (truthy) 19:22 warning truthy value should be one of [false, true] (truthy) 28:22 warning truthy value should be one of [false, true] (truthy) 33:22 warning truthy value should be one of [false, true] (truthy) 38:22 warning truthy value should be one of [false, true] (truthy) 55:4 warning missing starting space in comment (comments) 57:89 error line too long (89 > 88 characters) (line-length) 67:27 error trailing spaces (trailing-spaces) 68:1 error duplication of key "firewall" in mapping (key-duplicates) 69:12 warning truthy value should be one of [false, true] (truthy) 70:12 warning truthy value should be one of [false, true] (truthy) 71:11 warning truthy value should be one of [false, true] (truthy) 74:15 warning truthy value should be one of [false, true] (truthy) test/salt/pillar/default.pillar.sls 1:1 warning missing document start "---" (document-start) 2:12 warning truthy value should be one of [false, true] (truthy) 3:12 warning truthy value should be one of [false, true] (truthy) 4:11 warning truthy value should be one of [false, true] (truthy) 5:9 warning truthy value should be one of [false, true] (truthy) 10:22 warning truthy value should be one of [false, true] (truthy) 16:22 warning truthy value should be one of [false, true] (truthy) 21:22 warning truthy value should be one of [false, true] (truthy) 33:4 warning missing starting space in comment (comments) 35:89 error line too long (89 > 88 characters) (line-length) test/salt/pillar/tables.pillar.sls 2:27 error trailing spaces (trailing-spaces) 3:1 warning missing document start "---" (document-start) 4:12 warning truthy value should be one of [false, true] (truthy) 5:12 warning truthy value should be one of [false, true] (truthy) 6:11 warning truthy value should be one of [false, true] (truthy) 9:15 warning truthy value should be one of [false, true] (truthy) 37:4 warning missing starting space in comment (comments) 39:89 error line too long (89 > 88 characters) (line-length) ```
1 parent cda07b5 commit 9721448

File tree

9 files changed

+82
-35
lines changed

9 files changed

+82
-35
lines changed

.travis.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
---
44
stages:
55
- test
6-
- commitlint
6+
- lint
77
- name: release
88
if: branch = master AND type != pull_request
99

@@ -65,16 +65,21 @@ script:
6565

6666
jobs:
6767
include:
68-
# Define the commitlint stage
69-
- stage: commitlint
68+
# Define the `lint` stage (runs `yamllint` and `commitlint`)
69+
- stage: lint
7070
language: node_js
7171
node_js: lts/*
7272
before_install: skip
7373
script:
74+
# Install and run `yamllint`
75+
- pip install --user yamllint
76+
# yamllint disable-line rule:line-length
77+
- yamllint -s . .yamllint pillar.example test/salt/pillar/default.pillar.sls test/salt/pillar/tables.pillar.sls
78+
# Install and run `commitlint`
7479
- npm install @commitlint/config-conventional -D
7580
- npm install @commitlint/travis-cli -D
7681
- commitlint-travis
77-
# Define the release stage that runs semantic-release
82+
# Define the release stage that runs `semantic-release`
7883
- stage: release
7984
language: node_js
8085
node_js: lts/*

.yamllint

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
# Extend the `default` configuration provided by `yamllint`
5+
extends: default
6+
7+
# Files to ignore completely
8+
# 1. All YAML files under directory `node_modules/`, introduced during the Travis run
9+
ignore: |
10+
node_modules/
11+
12+
rules:
13+
key-duplicates:
14+
ignore: |
15+
pillar.example
16+
line-length:
17+
# Increase from default of `80`
18+
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
19+
max: 88

iptables/defaults.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=yaml
3+
---
34
firewall:
45
enabled: false
56
install: false
@@ -47,4 +48,3 @@ firewall:
4748
POSTROUTING:
4849
policy: ACCEPT
4950
rules: {}
50-

iptables/osfamilymap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=yaml
3+
---
34
Debian:
45
pkgs:
56
- iptables

pillar.example

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
14
firewall:
2-
install: True
3-
enabled: True
4-
strict: True
5-
ipv6: True
5+
install: true
6+
enabled: true
7+
strict: true
8+
ipv6: true
69
services:
710
ssh:
8-
block_nomatch: True
11+
block_nomatch: true
912
ips_allow:
1013
- 10.0.0.0/8
1114
- 172.16.0.0/12
1215
- 192.168.0.0/16
1316
http:
14-
block_nomatch: False
17+
block_nomatch: false
1518
protos:
1619
- udp
1720
- tcp
1821
snmp:
19-
block_nomatch: False
22+
block_nomatch: false
2023
protos:
2124
- udp
2225
- tcp
@@ -25,17 +28,17 @@ firewall:
2528

2629
services_ipv6:
2730
ssh:
28-
block_nomatch: False
31+
block_nomatch: false
2932
ips_allow:
3033
- 2a02:2028:773:d01:10a5:f34f:e7ff:f55b/64
3134
- 2a02:2028:773:d01:1814:28ef:e91b:70b8/64
3235
http:
33-
block_nomatch: False
36+
block_nomatch: false
3437
protos:
3538
- udp
3639
- tcp
3740
snmp:
38-
block_nomatch: False
41+
block_nomatch: false
3942
protos:
4043
- udp
4144
- tcp
@@ -52,9 +55,11 @@ firewall:
5255
ips_allow:
5356
- 2a02:2028:773:d01:1814:28ef:e91b:70b8/64
5457

55-
#Support nat (ipv4 only)
58+
# yamllint disable rule:line-length
59+
# Support nat (ipv4 only)
5660
# iptables -t nat -A POSTROUTING -o eth0 -s 192.168.18.0/24 -d 10.20.0.2 -j MASQUERADE
5761
# iptables -t nat -A POSTROUTING -o eth0 -s 192.168.18.0/24 -d 172.31.0.2 -j MASQUERADE
62+
# yamllint enable rule:line-length
5863
nat:
5964
eth0:
6065
rules:
@@ -64,14 +69,14 @@ firewall:
6469
### Using the tables.sls state
6570

6671
# In this example we iterate over tables (filter, nat, mangle) and
67-
# adds the desired entries
72+
# adds the desired entries
6873
firewall:
69-
install: True
70-
enabled: True
71-
strict: True
74+
install: true
75+
enabled: true
76+
strict: true
7277

7378
# To use tables, leave services undefined and set this to true
74-
use_tables: True
79+
use_tables: true
7580

7681
filter:
7782
INPUT:

test/integration/default/inspec.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
14
name: default
25
title: iptables formula
36
maintainer: SaltStack Formulas

test/integration/tables/inspec.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
14
name: tables
25
title: iptables formula
36
maintainer: SaltStack Formulas
47
license: Apache-2.0
8+
# yamllint disable-line rule:line-length
59
summary: Verify that iptables is installed and configured using tables defined in pillars
610
supports:
711
- platform-name: debian

test/salt/pillar/default.pillar.sls

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
14
firewall:
2-
install: True
3-
enabled: True
4-
strict: True
5-
ipv6: False
5+
install: true
6+
enabled: true
7+
strict: true
8+
ipv6: false
69
## To manage the firewall writing rules instead of services, check
710
## the `pillar.tables.example` for examples
811
services:
912
ssh:
10-
block_nomatch: True
13+
block_nomatch: true
1114
ips_allow:
1215
- 10.0.0.0/8
1316
- 172.16.0.0/12
1417
- 192.168.0.0/16
1518
http:
16-
block_nomatch: False
19+
block_nomatch: false
1720
protos:
1821
- udp
1922
- tcp
2023
snmp:
21-
block_nomatch: False
24+
block_nomatch: false
2225
protos:
2326
- udp
2427
- tcp
@@ -30,9 +33,11 @@ firewall:
3033
ips_allow:
3134
- 10.0.0.0/8
3235

33-
#Support nat (ipv4 only)
36+
# yamllint disable rule:line-length
37+
# Support nat (ipv4 only)
3438
# iptables -t nat -A POSTROUTING -o eth0 -s 192.168.18.0/24 -d 10.20.0.2 -j MASQUERADE
3539
# iptables -t nat -A POSTROUTING -o eth0 -s 192.168.18.0/24 -d 172.31.0.2 -j MASQUERADE
40+
# yamllint enable rule:line-length
3641
nat:
3742
eth0:
3843
rules:

test/salt/pillar/tables.pillar.sls

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
14
# In this example we iterate over tables (filter, nat, mangle) and
2-
# adds the desired entries
5+
# adds the desired entries
36
firewall:
4-
install: True
5-
enabled: True
6-
strict: True
7+
install: true
8+
enabled: true
9+
strict: true
710

811
# To use tables, leave services undefined and set this to true
9-
use_tables: True
12+
use_tables: true
1013

1114
whitelist:
1215
networks:
@@ -34,9 +37,11 @@ firewall:
3437
dport: 2222
3538
jump: REJECT
3639

37-
#Suppport nat
40+
# yamllint disable rule:line-length
41+
# Suppport nat
3842
# iptables -t nat -A POSTROUTING -o eth0 -s 192.168.18.0/24 -d 10.20.0.2 -j MASQUERADE
3943
# iptables -t nat -A POSTROUTING -o eth0 -s 192.168.18.0/24 -d 172.31.0.2 -j MASQUERADE
44+
# yamllint enable rule:line-length
4045
nat:
4146
POSTROUTING:
4247
rules:

0 commit comments

Comments
 (0)