Skip to content

Commit 5e6d4b2

Browse files
committed
cleanups
1 parent 8a3e9f8 commit 5e6d4b2

File tree

7 files changed

+55
-35
lines changed

7 files changed

+55
-35
lines changed

go.mod

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@ require (
99
github.com/jung-kurt/gofpdf v1.16.2
1010
github.com/mattn/go-shellwords v1.0.12
1111
github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de
12-
github.com/shopspring/decimal v1.3.1
12+
github.com/shopspring/decimal v1.4.0
1313
github.com/spf13/pflag v1.0.5
1414
github.com/wcharczuk/go-chart v2.0.1+incompatible
1515
github.com/xuri/excelize/v2 v2.8.1
16-
golang.org/x/crypto v0.21.0
16+
golang.org/x/crypto v0.22.0
1717
gopkg.in/yaml.v3 v3.0.1
1818
)
1919

2020
require (
21+
github.com/bytedance/sonic/loader v0.1.1 // indirect
2122
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
23+
github.com/cloudwego/base64x v0.1.3 // indirect
24+
github.com/cloudwego/iasm v0.2.0 // indirect
2225
github.com/davecgh/go-spew v1.1.1 // indirect
2326
github.com/gin-contrib/sse v0.1.0 // indirect
2427
github.com/go-playground/locales v0.14.1 // indirect
@@ -36,29 +39,29 @@ require (
3639
github.com/richardlehane/mscfb v1.0.4 // indirect
3740
github.com/richardlehane/msoleps v1.0.3 // indirect
3841
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
39-
golang.org/x/sys v0.18.0 // indirect
42+
golang.org/x/sys v0.19.0 // indirect
4043
golang.org/x/text v0.14.0 // indirect
4144
)
4245

4346
require (
4447
github.com/akedrou/textdiff v0.0.0-20230423230343-2ebdcebdccc1
4548
github.com/blend/go-sdk v1.20220411.3 // indirect
46-
github.com/bytedance/sonic v1.11.3 // indirect
49+
github.com/bytedance/sonic v1.11.5 // indirect
4750
github.com/chenzhuoyu/iasm v0.9.1 // indirect
4851
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
4952
github.com/go-playground/validator/v10 v10.19.0 // indirect
5053
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
5154
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
5255
github.com/mattn/go-isatty v0.0.20 // indirect
53-
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
56+
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
5457
github.com/phpdave11/gofpdi v1.0.13 // indirect
5558
github.com/spf13/cobra v1.8.0
5659
github.com/stretchr/testify v1.9.0
5760
github.com/ugorji/go/codec v1.2.12 // indirect
58-
github.com/xuri/efp v0.0.0-20231025114914-d1ff6096ae53 // indirect
61+
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d // indirect
5962
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 // indirect
6063
golang.org/x/arch v0.7.0 // indirect
6164
golang.org/x/image v0.15.0 // indirect
62-
golang.org/x/net v0.23.0 // indirect
65+
golang.org/x/net v0.24.0 // indirect
6366
google.golang.org/protobuf v1.33.0 // indirect
6467
)

go.sum

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1
77
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
88
github.com/bytedance/sonic v1.11.3 h1:jRN+yEjakWh8aK5FzrciUHG8OFXK+4/KrAX/ysEtHAA=
99
github.com/bytedance/sonic v1.11.3/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
10+
github.com/bytedance/sonic v1.11.5 h1:G00FYjjqll5iQ1PYXynbg/hyzqBqavH8Mo9/oTopd9k=
11+
github.com/bytedance/sonic v1.11.5/go.mod h1:X2PC2giUdj/Cv2lliWFLk6c/DUQok5rViJSemeB0wDw=
12+
github.com/bytedance/sonic/loader v0.1.0/go.mod h1:UmRT+IRTGKz/DAkzcEGzyVqQFJ7H9BqwBO3pm9H/+HY=
13+
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
14+
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
1015
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
1116
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
1217
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
@@ -20,6 +25,10 @@ github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI
2025
github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk=
2126
github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
2227
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
28+
github.com/cloudwego/base64x v0.1.3 h1:b5J/l8xolB7dyDTTmhJP2oTs5LdrjyrUFuNxdfq5hAg=
29+
github.com/cloudwego/base64x v0.1.3/go.mod h1:1+1K5BUHIQzyapgpF7LwvOGAEDicKtt1umPV+aN8pi8=
30+
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
31+
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
2332
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
2433
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2534
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -74,6 +83,8 @@ github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de h1:D5x39vF5KCwKQaw+OC9
7483
github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de/go.mod h1:kJun4WP5gFuHZgRjZUWWuH1DTxCtxbHDOIJsudS8jzY=
7584
github.com/pelletier/go-toml/v2 v2.2.0 h1:QLgLl2yMN7N+ruc31VynXs1vhMZa7CeHHejIeBAsoHo=
7685
github.com/pelletier/go-toml/v2 v2.2.0/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
86+
github.com/pelletier/go-toml/v2 v2.2.1 h1:9TA9+T8+8CUCO2+WYnDLCgrYi9+omqKXyjDtosvtEhg=
87+
github.com/pelletier/go-toml/v2 v2.2.1/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
7788
github.com/phpdave11/gofpdi v1.0.7/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
7889
github.com/phpdave11/gofpdi v1.0.13 h1:o61duiW8M9sMlkVXWlvP92sZJtGKENvW3VExs6dZukQ=
7990
github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
@@ -91,6 +102,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
91102
github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=
92103
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
93104
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
105+
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
106+
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
94107
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
95108
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
96109
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
@@ -116,6 +129,8 @@ github.com/wcharczuk/go-chart v2.0.1+incompatible h1:0pz39ZAycJFF7ju/1mepnk26RLV
116129
github.com/wcharczuk/go-chart v2.0.1+incompatible/go.mod h1:PF5tmL4EIx/7Wf+hEkpCqYi5He4u90sw+0+6FhrryuE=
117130
github.com/xuri/efp v0.0.0-20231025114914-d1ff6096ae53 h1:Chd9DkqERQQuHpXjR/HSV1jLZA6uaoiwwH3vSuF3IW0=
118131
github.com/xuri/efp v0.0.0-20231025114914-d1ff6096ae53/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
132+
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d h1:llb0neMWDQe87IzJLS4Ci7psK/lVsjIS2otl+1WyRyY=
133+
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
119134
github.com/xuri/excelize/v2 v2.8.1 h1:pZLMEwK8ep+CLIUWpWmvW8IWE/yxqG0I1xcN6cVMGuQ=
120135
github.com/xuri/excelize/v2 v2.8.1/go.mod h1:oli1E4C3Pa5RXg1TBXn4ENCXDV5JUMlBluUhG7c+CEE=
121136
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 h1:hPVCafDV85blFTabnqKgNhDCkJX25eik94Si9cTER4A=
@@ -125,16 +140,22 @@ golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc=
125140
golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
126141
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
127142
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
143+
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
144+
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
128145
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
129146
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
130147
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
131148
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
132149
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
150+
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
151+
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
133152
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
134153
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
135154
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
136155
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
137156
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
157+
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
158+
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
138159
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
139160
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
140161
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=

pkg/common/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ func (c *Config) Load(configFilename string) error {
147147
values := make(map[string]any)
148148
parseError := json.Unmarshal(data, &values)
149149
if parseError != nil {
150-
return fmt.Errorf("failed to parse config file %q: %v", configFilename, parseError)
150+
return fmt.Errorf("failed to parse config file %q: %w", configFilename, parseError)
151151
}
152152

153153
var config Config
154154
unmarshalError := json.Unmarshal(data, &config)
155155
if unmarshalError != nil {
156-
return fmt.Errorf("failed to parse config file %q: %v", configFilename, unmarshalError)
156+
return fmt.Errorf("failed to parse config file %q: %w", configFilename, unmarshalError)
157157
}
158158

159159
c.Merge(config, values)
@@ -162,13 +162,13 @@ func (c *Config) Load(configFilename string) error {
162162
c.TempFolder = c.CleanPath(c.TempFolder)
163163
tempDirError := os.MkdirAll(c.TempFolder, 0700)
164164
if tempDirError != nil {
165-
errorList = append(errorList, fmt.Errorf("failed to create temp dir %q: %v", c.TempFolder, tempDirError))
165+
errorList = append(errorList, fmt.Errorf("failed to create temp dir %q: %w", c.TempFolder, tempDirError))
166166
}
167167

168168
c.OutputFolder = c.CleanPath(c.OutputFolder)
169169
outDirError := os.MkdirAll(c.OutputFolder, 0700)
170170
if outDirError != nil {
171-
errorList = append(errorList, fmt.Errorf("failed to create output dir %q: %v", c.OutputFolder, outDirError))
171+
errorList = append(errorList, fmt.Errorf("failed to create output dir %q: %w", c.OutputFolder, outDirError))
172172
}
173173

174174
c.AppFolder = c.CleanPath(c.AppFolder)

pkg/script/risk-rule.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package script
22

33
import (
4-
"embed"
54
"fmt"
65
"github.com/threagile/threagile/pkg/input"
76
"github.com/threagile/threagile/pkg/security/types"
@@ -84,7 +83,7 @@ func (what *RiskRule) GenerateRisks(parsedModel *types.Model) ([]*types.Risk, er
8483
return newRisks, nil
8584
}
8685

87-
func (what *RiskRule) Load(fileSystem embed.FS, path string, entry fs.DirEntry) error {
86+
func (what *RiskRule) Load(fileSystem fs.FS, path string, entry fs.DirEntry) error {
8887
if entry.IsDir() {
8988
return nil
9089
}
@@ -97,9 +96,10 @@ func (what *RiskRule) Load(fileSystem embed.FS, path string, entry fs.DirEntry)
9796
return nil
9897
}
9998

100-
func (what *RiskRule) loadRiskRule(fileSystem embed.FS, filename string) error {
99+
func (what *RiskRule) loadRiskRule(fileSystem fs.FS, filename string) error {
101100
scriptFilename := filepath.Clean(filename)
102-
ruleData, ruleReadError := fileSystem.ReadFile(scriptFilename)
101+
102+
ruleData, ruleReadError := fs.ReadFile(fileSystem, scriptFilename)
103103
if ruleReadError != nil {
104104
return fmt.Errorf("error reading risk category: %w\n", ruleReadError)
105105
}

pkg/security/risks/scripts/accidental-secret-leak.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ risk_assessment:
2929
The risk rating depends on the sensitivity of the technical asset itself and of the data assets processed.
3030
false_positives:
3131
Usually no false positives.
32-
is_built_in: true
3332

3433
script:
3534
risk:

pkg/security/types/risk-category.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@ package types
33
import "strings"
44

55
type RiskCategory struct {
6-
ID string `json:"id,omitempty" yaml:"id,omitempty"`
7-
Title string `json:"title,omitempty" yaml:"title,omitempty"`
8-
Description string `json:"description,omitempty" yaml:"description,omitempty"`
9-
Impact string `json:"impact,omitempty" yaml:"impact,omitempty"`
10-
ASVS string `json:"asvs,omitempty" yaml:"asvs,omitempty"`
11-
CheatSheet string `json:"cheat_sheet,omitempty" yaml:"cheat_sheet,omitempty"`
12-
Action string `json:"action,omitempty" yaml:"action,omitempty"`
13-
Mitigation string `json:"mitigation,omitempty" yaml:"mitigation,omitempty"`
14-
Check string `json:"check,omitempty" yaml:"check,omitempty"`
15-
Function RiskFunction `json:"function,omitempty" yaml:"function,omitempty"`
16-
STRIDE STRIDE `json:"stride,omitempty" yaml:"stride,omitempty"`
17-
DetectionLogic string `json:"detection_logic,omitempty" yaml:"detection_logic,omitempty"`
18-
RiskAssessment string `json:"risk_assessment,omitempty" yaml:"risk_assessment,omitempty"`
19-
FalsePositives string `json:"false_positives,omitempty" yaml:"false_positives,omitempty"`
20-
ModelFailurePossibleReason bool `json:"model_failure_possible_reason,omitempty" yaml:"model_failure_possible_reason,omitempty"`
21-
CWE int `json:"cwe,omitempty" yaml:"cwe,omitempty"`
22-
IsBuiltIn bool `json:"is_built_in,omitempty" yaml:"is_built_in,omitempty"`
23-
Script map[string]any `json:"script,omitempty" yaml:"script,omitempty"`
6+
ID string `json:"id,omitempty" yaml:"id,omitempty"`
7+
Title string `json:"title,omitempty" yaml:"title,omitempty"`
8+
Description string `json:"description,omitempty" yaml:"description,omitempty"`
9+
Impact string `json:"impact,omitempty" yaml:"impact,omitempty"`
10+
ASVS string `json:"asvs,omitempty" yaml:"asvs,omitempty"`
11+
CheatSheet string `json:"cheat_sheet,omitempty" yaml:"cheat_sheet,omitempty"`
12+
Action string `json:"action,omitempty" yaml:"action,omitempty"`
13+
Mitigation string `json:"mitigation,omitempty" yaml:"mitigation,omitempty"`
14+
Check string `json:"check,omitempty" yaml:"check,omitempty"`
15+
Function RiskFunction `json:"function,omitempty" yaml:"function,omitempty"`
16+
STRIDE STRIDE `json:"stride,omitempty" yaml:"stride,omitempty"`
17+
DetectionLogic string `json:"detection_logic,omitempty" yaml:"detection_logic,omitempty"`
18+
RiskAssessment string `json:"risk_assessment,omitempty" yaml:"risk_assessment,omitempty"`
19+
FalsePositives string `json:"false_positives,omitempty" yaml:"false_positives,omitempty"`
20+
ModelFailurePossibleReason bool `json:"model_failure_possible_reason,omitempty" yaml:"model_failure_possible_reason,omitempty"`
21+
CWE int `json:"cwe,omitempty" yaml:"cwe,omitempty"`
2422
}
2523

2624
type RiskCategories []*RiskCategory

test/risk-category.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ risk_assessment:
2929
The risk rating depends on the sensitivity of the technical asset itself and of the data assets processed.
3030
false_positives:
3131
Usually no false positives.
32-
is_built_in: true
3332

3433
script:
3534
risk:

0 commit comments

Comments
 (0)