Skip to content

Commit 12a779f

Browse files
authored
Fix/query id type (#281)
* revert queryId to generic interface
1 parent 5122db9 commit 12a779f

File tree

13 files changed

+44
-35
lines changed

13 files changed

+44
-35
lines changed

.goreleaser.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,4 @@ brews:
5757
test: |
5858
system "#{bin}/cx version"
5959
install: |-
60-
pkgshare.mkpath
61-
cp_r "assets", pkgshare
6260
bin.install "cx"

internal/commands/result.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func parseResults(results *wrappers.ScanResultsCollection) ([]wrappers.SarifDriv
350350
func findRule(ruleIds map[interface{}]bool, result *wrappers.ScanResult) *wrappers.SarifDriverRule {
351351
var sarifRule wrappers.SarifDriverRule
352352

353-
if result.ScanResultData.QueryID == 0 {
353+
if result.ScanResultData.QueryID == nil {
354354
sarifRule.ID = result.ID
355355
} else {
356356
sarifRule.ID = getRuleID(result.ScanResultData.QueryID)

internal/commands/scan.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func findProject(projectName string) (string, error) {
318318
projectsWrapper := wrappers.NewHTTPProjectsWrapper(projects)
319319
resp, _, err := projectsWrapper.Get(params)
320320
if err != nil {
321-
return "", errors.Wrapf(err, "%s\n", failedGettingAll)
321+
return "", err
322322
}
323323
if resp.FilteredTotalCount > 0 {
324324
for i := 0; i < len(resp.Projects); i++ {
@@ -329,7 +329,7 @@ func findProject(projectName string) (string, error) {
329329
} else {
330330
projectID, err = createProject(projectName)
331331
if err != nil {
332-
return "", errors.Wrapf(err, "%s", failedCreatingProj)
332+
return "", err
333333
}
334334
}
335335
return projectID, nil

internal/commands/util/configuration.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ const (
1818
)
1919

2020
var properties = map[string]bool{
21-
params.AstAPIKey: true,
2221
params.BaseURIKey: true,
2322
params.BaseAuthURIKey: true,
2423
params.TenantKey: true,
25-
params.ProxyTypeKey: true,
2624
params.ProxyKey: true,
27-
params.AccessKeySecretConfigKey: true,
25+
params.ProxyTypeKey: true,
2826
params.AccessKeyIDConfigKey: true,
27+
params.AccessKeySecretConfigKey: true,
28+
params.AstAPIKey: true,
29+
params.BranchKey: true,
30+
params.ScaToolKey: true,
31+
params.ClientTimeoutKey: true,
2932
}
3033

3134
func NewConfigCommand() *cobra.Command {

internal/commands/util/env.go

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,26 @@ import (
55
"os"
66

77
"github.com/MakeNowJust/heredoc"
8-
98
"github.com/spf13/cobra"
109
)
1110

11+
const formatString = "%30v: %s\n"
12+
1213
func NewEnvCheckCommand() *cobra.Command {
1314
cmd := &cobra.Command{
1415
Use: "env",
1516
Short: "Shows the current profiles configuration properties",
16-
Example: heredoc.Doc(`
17+
Example: heredoc.Doc(
18+
`
1719
$ cx utils env
18-
`),
20+
`,
21+
),
1922
Annotations: map[string]string{
20-
"command:doc": heredoc.Doc(`
23+
"command:doc": heredoc.Doc(
24+
`
2125
https://checkmarx.atlassian.net/wiki/x/VJGXtw
22-
`),
26+
`,
27+
),
2328
},
2429
RunE: runEnvChecks(),
2530
}
@@ -29,24 +34,9 @@ func NewEnvCheckCommand() *cobra.Command {
2934
func runEnvChecks() func(cmd *cobra.Command, args []string) error {
3035
return func(cmd *cobra.Command, args []string) error {
3136
fmt.Printf("\nDetected Environment Variables:\n\n")
32-
fmt.Printf("%30v", "CX_BASE_URI: ")
33-
fmt.Println(os.Getenv("CX_BASE_URI"))
34-
fmt.Printf("%30v", "CX_BASE_AUTH_URI: ")
35-
fmt.Println(os.Getenv("CX_BASE_AUTH_URI"))
36-
fmt.Printf("%30v", "CX_TENANT: ")
37-
fmt.Println(os.Getenv("CX_TENANT"))
38-
fmt.Printf("%30v", "HTTP_PROXY: ")
39-
fmt.Println(os.Getenv("HTTP_PROXY"))
40-
fmt.Printf("%30v", "HTTP_PROXY_TYPE: ")
41-
fmt.Println(os.Getenv("CX_PROXY_AUTH_TYPE"))
42-
fmt.Printf("%30v", "CX_CLIENT_ID: ")
43-
fmt.Println(os.Getenv("CX_CLIENT_ID"))
44-
fmt.Printf("%30v", "CX_CLIENT_SECRET: ")
45-
fmt.Println(os.Getenv("CX_CLIENT_SECRET"))
46-
fmt.Printf("%30v", "CX_APIKEY: ")
47-
fmt.Println(os.Getenv("CX_APIKEY"))
48-
fmt.Printf("%30v", "CX_BRANCH: ")
49-
fmt.Println(os.Getenv("CX_BRANCH"))
37+
for param := range properties {
38+
fmt.Printf(formatString, param, os.Getenv(param))
39+
}
5040
return nil
5141
}
5242
}

internal/params/filters.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,5 @@ var BaseFilters = []string{
120120
"requirements.txt",
121121
"requirement.txt",
122122
"composer.lock",
123+
"Dockerfile",
123124
}

internal/wrappers/results-json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type ScanResultPackageData struct {
7070
}
7171

7272
type ScanResultData struct {
73-
QueryID uint64 `json:"queryId,omitempty"`
73+
QueryID interface{} `json:"queryId,omitempty"`
7474
QueryName string `json:"queryName,omitempty"`
7575
Group string `json:"group,omitempty"`
7676
ResultHash string `json:"resultHash,omitempty"`

test/integration/data/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Example: docker build . -t dsvw && docker run -p 65412:65412 dsvw
2+
3+
FROM alpine:3.11
4+
5+
RUN apk --no-cache add git python3 py-lxml \
6+
&& rm -rf /var/cache/apk/*
7+
8+
WORKDIR /
9+
RUN git clone https://github.com/stamparm/DSVW
10+
11+
WORKDIR /DSVW
12+
RUN sed -i 's/127.0.0.1/0.0.0.0/g' dsvw.py
13+
14+
EXPOSE 65412
15+
16+
CMD ["python3", "dsvw.py"]

0 commit comments

Comments
 (0)