File tree 4 files changed +14
-22
lines changed
4 files changed +14
-22
lines changed Original file line number Diff line number Diff line change 1
- // (c) Copyright 2016 Hewlett Packard Enterprise Development LP
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
- package html
16
-
17
- const templateContent = `
18
1
<!doctype html>
19
2
< html lang ="en ">
20
3
< head >
454
437
) ;
455
438
</ script >
456
439
</ body >
457
- </html>`
440
+ </ html >
Original file line number Diff line number Diff line change 1
1
package html
2
2
3
3
import (
4
+
5
+ // use go embed to import template
6
+ _ "embed"
4
7
"html/template"
5
8
"io"
6
9
7
10
"github.com/securego/gosec/v2"
8
11
)
9
12
13
+ //go:embed template.html
14
+ var templateContent string
15
+
10
16
// WriteReport write a report in html format to the output writer
11
17
func WriteReport (w io.Writer , data * gosec.ReportInfo ) error {
12
18
t , e := template .New ("gosec" ).Parse (templateContent )
Original file line number Diff line number Diff line change 1
- package text
2
-
3
- const templateContent = `Results:
1
+ Results:
4
2
{{range $filePath,$fileErrors := .Errors}}
5
3
Golang errors in file: [{{ $filePath }}]:
6
4
{{range $index, $error := $fileErrors}}
@@ -23,4 +21,3 @@ Golang errors in file: [{{ $filePath }}]:
23
21
{{- danger .Stats.NumFound }}
24
22
{{- end }}
25
23
26
- `
Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ package text
3
3
import (
4
4
"bufio"
5
5
"bytes"
6
+
7
+ // use go embed to import template
8
+ _ "embed"
6
9
"fmt"
7
10
"io"
8
11
"strconv"
17
20
errorTheme = color .New (color .FgLightWhite , color .BgRed )
18
21
warningTheme = color .New (color .FgBlack , color .BgYellow )
19
22
defaultTheme = color .New (color .FgWhite , color .BgBlack )
23
+
24
+ //go:embed template.txt
25
+ templateContent string
20
26
)
21
27
22
28
// WriteReport write a (colorized) report in text format
You can’t perform that action at this time.
0 commit comments