Skip to content

Commit 7992368

Browse files
Remove line continuations in all run steps. (#2335)
Signed-off-by: Spencer Schrock <sschrock@google.com> Signed-off-by: Spencer Schrock <sschrock@google.com>
1 parent 4b99a3a commit 7992368

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

checks/fileparser/github_workflow.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,9 @@ func stepsMatch(stepToMatch *JobMatcherStep, step *actionlint.Step) bool {
426426
if run == nil {
427427
return false
428428
}
429+
withoutLineContinuations := regexp.MustCompile("\\\\(\n|\r|\r\n)").ReplaceAllString(run.Value, "")
429430
r := regexp.MustCompile(stepToMatch.Run)
430-
if !r.MatchString(run.Value) {
431+
if !r.MatchString(withoutLineContinuations) {
431432
return false
432433
}
433434
}

checks/fileparser/github_workflow_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,11 @@ func TestIsPackagingWorkflow(t *testing.T) {
938938
filename: "../testdata/.github/workflows/github-workflow-packaging-maven.yaml",
939939
expected: true,
940940
},
941+
{
942+
name: "maven publish multi-line",
943+
filename: "../testdata/.github/workflows/github-workflow-packaging-maven-multi-line.yaml",
944+
expected: true,
945+
},
941946
{
942947
name: "gradle publish",
943948
filename: "../testdata/.github/workflows/github-workflow-packaging-gradle.yaml",
@@ -1004,7 +1009,7 @@ func TestIsPackagingWorkflow(t *testing.T) {
10041009
}
10051010
workflow, errs := actionlint.Parse(content)
10061011
if len(errs) > 0 && workflow == nil {
1007-
t.Errorf("cannot parse file: %v", err)
1012+
t.Errorf("cannot parse file: %v", errs)
10081013
}
10091014
p := strings.Replace(tt.filename, "../testdata/", "", 1)
10101015

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2022 Security Scorecard Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- uses: actions/setup-java@v1
21+
- run: |
22+
mvn \
23+
clean deploy

0 commit comments

Comments
 (0)