Skip to content

Commit 16cb088

Browse files
authored
(Fix): Change dockerfile regex to match re2 (#999)
Reverts #943 and also adds an ignore to handle the original request Fixes the error log `Error parsing '(?i)(?:^|/)Dockerfile\.(?!.*\.dockerignore$).+$': invalid perl operator: (?!`, since re2 doesn't support negative matches. Tested that the log is no longer there and `trunk check query` produces the correct LQRs
1 parent 64dfa58 commit 16cb088

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

linters/hadolint/test_data/hadolint_v2.10.0_CUSTOM.check.shot

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ exports[`Testing linter hadolint test CUSTOM 1`] = `
2626
],
2727
"verb": "TRUNK_VERB_CHECK",
2828
},
29+
{
30+
"command": "lint",
31+
"fileGroupName": "docker",
32+
"linter": "hadolint",
33+
"paths": [
34+
"test_data/Dockerfile.empty",
35+
],
36+
"verb": "TRUNK_VERB_CHECK",
37+
},
2938
{
3039
"command": "lint",
3140
"fileGroupName": "docker",
@@ -44,6 +53,15 @@ exports[`Testing linter hadolint test CUSTOM 1`] = `
4453
],
4554
"verb": "TRUNK_VERB_CHECK",
4655
},
56+
{
57+
"command": "lint",
58+
"fileGroupName": "docker",
59+
"linter": "hadolint",
60+
"paths": [
61+
"test_data/nested/Dockerfile.debug",
62+
],
63+
"verb": "TRUNK_VERB_CHECK",
64+
},
4765
{
4866
"command": "lint",
4967
"fileGroupName": "docker",
@@ -72,6 +90,16 @@ exports[`Testing linter hadolint test CUSTOM 1`] = `
7290
"upstream": true,
7391
"verb": "TRUNK_VERB_CHECK",
7492
},
93+
{
94+
"command": "lint",
95+
"fileGroupName": "docker",
96+
"linter": "hadolint",
97+
"paths": [
98+
"test_data/Dockerfile.empty",
99+
],
100+
"upstream": true,
101+
"verb": "TRUNK_VERB_CHECK",
102+
},
75103
{
76104
"command": "lint",
77105
"fileGroupName": "docker",
@@ -92,6 +120,16 @@ exports[`Testing linter hadolint test CUSTOM 1`] = `
92120
"upstream": true,
93121
"verb": "TRUNK_VERB_CHECK",
94122
},
123+
{
124+
"command": "lint",
125+
"fileGroupName": "docker",
126+
"linter": "hadolint",
127+
"paths": [
128+
"test_data/nested/Dockerfile.debug",
129+
],
130+
"upstream": true,
131+
"verb": "TRUNK_VERB_CHECK",
132+
},
95133
{
96134
"command": "lint",
97135
"fileGroupName": "docker",

linters/hadolint/test_data/hadolint_v2.12.1-beta_CUSTOM.check.shot

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ exports[`Testing linter hadolint test CUSTOM 1`] = `
2626
],
2727
"verb": "TRUNK_VERB_CHECK",
2828
},
29+
{
30+
"command": "lint",
31+
"fileGroupName": "docker",
32+
"linter": "hadolint",
33+
"paths": [
34+
"test_data/Dockerfile.empty",
35+
],
36+
"verb": "TRUNK_VERB_CHECK",
37+
},
2938
{
3039
"command": "lint",
3140
"fileGroupName": "docker",
@@ -44,6 +53,15 @@ exports[`Testing linter hadolint test CUSTOM 1`] = `
4453
],
4554
"verb": "TRUNK_VERB_CHECK",
4655
},
56+
{
57+
"command": "lint",
58+
"fileGroupName": "docker",
59+
"linter": "hadolint",
60+
"paths": [
61+
"test_data/nested/Dockerfile.debug",
62+
],
63+
"verb": "TRUNK_VERB_CHECK",
64+
},
4765
{
4866
"command": "lint",
4967
"fileGroupName": "docker",
@@ -72,6 +90,16 @@ exports[`Testing linter hadolint test CUSTOM 1`] = `
7290
"upstream": true,
7391
"verb": "TRUNK_VERB_CHECK",
7492
},
93+
{
94+
"command": "lint",
95+
"fileGroupName": "docker",
96+
"linter": "hadolint",
97+
"paths": [
98+
"test_data/Dockerfile.empty",
99+
],
100+
"upstream": true,
101+
"verb": "TRUNK_VERB_CHECK",
102+
},
75103
{
76104
"command": "lint",
77105
"fileGroupName": "docker",
@@ -92,6 +120,16 @@ exports[`Testing linter hadolint test CUSTOM 1`] = `
92120
"upstream": true,
93121
"verb": "TRUNK_VERB_CHECK",
94122
},
123+
{
124+
"command": "lint",
125+
"fileGroupName": "docker",
126+
"linter": "hadolint",
127+
"paths": [
128+
"test_data/nested/Dockerfile.debug",
129+
],
130+
"upstream": true,
131+
"verb": "TRUNK_VERB_CHECK",
132+
},
95133
{
96134
"command": "lint",
97135
"fileGroupName": "docker",

linters/plugin.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ lint:
221221
# ?: is a non-capturing group, so that the RE2 DFA is more memory efficient
222222
# NOTE(Tyler): This is more strict than it realistically needs to be, but this partial match
223223
# and the file extensions provide a general enough capture.
224-
# Note that re2 does not support ?!, so this does not capture all correct cases.
225-
- (?i)(?:^|/)Dockerfile\.(?!.*\.dockerignore$).+$
224+
- (?i)(?:^|/)Dockerfile\..+$
226225
filenames:
227226
- dockerfile
228227
- Dockerfile
@@ -707,3 +706,6 @@ lint:
707706

708707
- linters: [osv-scanner]
709708
paths: ["**/go.sum"]
709+
710+
- linters: [checkov, hadolint, snyk, terrascan, trivy]
711+
paths: ["**/*.dockerignore"]

0 commit comments

Comments
 (0)