Skip to content

Commit

Permalink
refactor: migrate to github.com/DependencyTrack/client-go
Browse files Browse the repository at this point in the history
Signed-off-by: nscuro <nscuro@protonmail.com>
  • Loading branch information
nscuro committed Dec 2, 2022
1 parent 195e360 commit d8e80c7
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 423 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ For findings, the `input` document is structured as follows:

The available properties of those fields are documented here:

* [`component`](https://pkg.go.dev/github.com/nscuro/dtrack-client#Component)
* [`project`](https://pkg.go.dev/github.com/nscuro/dtrack-client#Project)
* [`vulnerability`](https://pkg.go.dev/github.com/nscuro/dtrack-client#Vulnerability)
* [`component`](https://pkg.go.dev/github.com/DependencyTrack/client-go#Component)
* [`project`](https://pkg.go.dev/github.com/DependencyTrack/client-go#Project)
* [`vulnerability`](https://pkg.go.dev/github.com/DependencyTrack/client-go#Vulnerability)

Obviously not all properties are always available.

Expand Down Expand Up @@ -278,9 +278,9 @@ For policy violations, the `input` document is structured as follows:

The available properties of those fields are documented here:

* [`component`](https://pkg.go.dev/github.com/nscuro/dtrack-client#Component)
* [`project`](https://pkg.go.dev/github.com/nscuro/dtrack-client#Project)
* [`policyViolation`](https://pkg.go.dev/github.com/nscuro/dtrack-client#PolicyViolation)
* [`component`](https://pkg.go.dev/github.com/DependencyTrack/client-go#Component)
* [`project`](https://pkg.go.dev/github.com/DependencyTrack/client-go#Project)
* [`policyViolation`](https://pkg.go.dev/github.com/DependencyTrack/client-go#PolicyViolation)

##### Example

Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module github.com/nscuro/dtapac
go 1.19

require (
github.com/DependencyTrack/client-go v0.8.0
github.com/go-chi/chi/v5 v5.0.7
github.com/google/uuid v1.3.0
github.com/iancoleman/orderedmap v0.2.0
github.com/invopop/jsonschema v0.7.0
github.com/nscuro/dtrack-client v0.7.0
github.com/peterbourgon/ff/v3 v3.3.0
github.com/prometheus/client_golang v1.14.0
github.com/rs/zerolog v1.28.0
Expand All @@ -33,7 +33,6 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
Expand All @@ -42,7 +41,6 @@ require (
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
github.com/opencontainers/runc v1.1.3 // indirect
Expand Down
411 changes: 11 additions & 400 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/analysis/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/nscuro/dtrack-client"
"github.com/DependencyTrack/client-go"
"github.com/rs/zerolog"

"github.com/nscuro/dtapac/internal/audit"
Expand Down
4 changes: 2 additions & 2 deletions internal/api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"net/http"
"strings"

"github.com/nscuro/dtrack-client"
"github.com/nscuro/dtrack-client/notification"
"github.com/DependencyTrack/client-go"
"github.com/DependencyTrack/client-go/notification"
"github.com/rs/zerolog"

"github.com/nscuro/dtapac/internal/audit"
Expand Down
2 changes: 1 addition & 1 deletion internal/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"net/http"
"time"

"github.com/DependencyTrack/client-go"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/nscuro/dtrack-client"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/zerolog"

Expand Down
6 changes: 3 additions & 3 deletions internal/apply/applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"fmt"
"io"

"github.com/DependencyTrack/client-go"
"github.com/google/uuid"
"github.com/nscuro/dtrack-client"
"github.com/rs/zerolog"
)

Expand Down Expand Up @@ -206,7 +206,7 @@ func (a *Applier) applyViolationAnalysis(ctx context.Context, analysisReq dtrack
// analysisService is an interface for parts of the Dependency-Track
// analysis API to make mocking in tests easier.
//
// This interface is implemented by https://pkg.go.dev/github.com/nscuro/dtrack-client#AnalysisService
// This interface is implemented by https://pkg.go.dev/github.com/DependencyTrack/client-go#AnalysisService
type analysisService interface {
Get(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) (dtrack.Analysis, error)
Create(context.Context, dtrack.AnalysisRequest) (dtrack.Analysis, error)
Expand All @@ -215,7 +215,7 @@ type analysisService interface {
// violationAnalysisService is an interface for parts of the Dependency-Track
// violation analysis API to make mocking in tests easier.
//
// This interface is implemented by https://pkg.go.dev/github.com/nscuro/dtrack-client#ViolationAnalysisService
// This interface is implemented by https://pkg.go.dev/github.com/DependencyTrack/client-go#ViolationAnalysisService
type violationAnalysisService interface {
Get(context.Context, uuid.UUID, uuid.UUID) (dtrack.ViolationAnalysis, error)
Update(context.Context, dtrack.ViolationAnalysisRequest) (dtrack.ViolationAnalysis, error)
Expand Down
2 changes: 1 addition & 1 deletion internal/audit/auditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"path"

"github.com/nscuro/dtrack-client"
"github.com/DependencyTrack/client-go"
"github.com/rs/zerolog"

"github.com/nscuro/dtapac/internal/opa"
Expand Down
2 changes: 1 addition & 1 deletion internal/audit/model.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package audit

import (
"github.com/nscuro/dtrack-client"
"github.com/DependencyTrack/client-go"
"github.com/rs/zerolog"
)

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync"
"syscall"

"github.com/nscuro/dtrack-client"
"github.com/DependencyTrack/client-go"
"github.com/peterbourgon/ff/v3"
"github.com/peterbourgon/ff/v3/ffcli"
"github.com/peterbourgon/ff/v3/ffyaml"
Expand Down
8 changes: 4 additions & 4 deletions tools/schema-generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"path/filepath"
"reflect"

"github.com/DependencyTrack/client-go"
"github.com/google/uuid"
"github.com/iancoleman/orderedmap"
"github.com/invopop/jsonschema"
"github.com/nscuro/dtrack-client"

"github.com/nscuro/dtapac/internal/audit"
)
Expand All @@ -38,9 +38,9 @@ func main() {

// Avoid endless recursion: PolicyViolation -> PolicyCondition -> Policy -> PolicyConditions -> Policy...
// See
// - https://pkg.go.dev/github.com/nscuro/dtrack-client#PolicyViolation
// - https://pkg.go.dev/github.com/nscuro/dtrack-client#PolicyCondition
// - https://pkg.go.dev/github.com/nscuro/dtrack-client#Policy
// - https://pkg.go.dev/github.com/DependencyTrack/client-go#PolicyViolation
// - https://pkg.go.dev/github.com/DependencyTrack/client-go#PolicyCondition
// - https://pkg.go.dev/github.com/DependencyTrack/client-go#Policy
if r == reflect.TypeOf(dtrack.Policy{}) || r == reflect.TypeOf(&dtrack.Policy{}) {
properties := orderedmap.New()
properties.Set("uuid", &jsonschema.Schema{
Expand Down

0 comments on commit d8e80c7

Please sign in to comment.