Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.26.1

require (
github.com/compliance-framework/agent v0.9.3
github.com/google/go-github/v71 v71.0.0
github.com/google/go-github/v93 v93.0.0
github.com/hashicorp/go-hclog v1.6.3
github.com/hashicorp/go-plugin v1.8.0
github.com/mitchellh/mapstructure v1.5.0
Expand All @@ -23,7 +23,7 @@ require (
github.com/goccy/go-json v0.10.5 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-containerregistry v0.21.2 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/go-querystring v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
github.com/lestrrat-go/blackmagic v1.0.4 // indirect
Expand Down
11 changes: 5 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/flatbuffers v25.2.10+incompatible h1:F3vclr7C3HpB1k9mxCGRMXq6FdUalZ6H/pNX4FP1v0Q=
github.com/google/flatbuffers v25.2.10+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/go-containerregistry v0.21.2 h1:vYaMU4nU55JJGFC9JR/s8NZcTjbE9DBBbvusTW9NeS0=
github.com/google/go-containerregistry v0.21.2/go.mod h1:ctO5aCaewH4AK1AumSF5DPW+0+R+d2FmylMJdp5G7p0=
github.com/google/go-github/v71 v71.0.0 h1:Zi16OymGKZZMm8ZliffVVJ/Q9YZreDKONCr+WUd0Z30=
github.com/google/go-github/v71 v71.0.0/go.mod h1:URZXObp2BLlMjwu0O8g4y6VBneUj2bCHgnI8FfgZ51M=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/go-github/v93 v93.0.0 h1:qElXPLv+XbSz1qrLdWyb0t3gSYGsWBTzr9T4/PZTCfk=
github.com/google/go-github/v93 v93.0.0/go.mod h1:l8I3rt4/mdjANKpg4Y84LEy9HJQCetUkZ8WTl2bPU8M=
github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfhIxNtP0=
github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 h1:JeSE6pjso5THxAzdVpqr6/geYxZytqFMBCOtn/ujyeo=
Expand Down Expand Up @@ -430,7 +430,6 @@ golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI=
golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa h1:mZHHdPZl0dbGHCflZgAq/Q468DWVFcU2whhB2KAo8fk=
Expand Down
10 changes: 5 additions & 5 deletions internal/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
policy_manager "github.com/compliance-framework/agent/policy-manager"

"github.com/compliance-framework/agent/runner/proto"
"github.com/google/go-github/v71/github"
"github.com/google/go-github/v93/github"
"github.com/hashicorp/go-hclog"
)

Expand Down Expand Up @@ -168,13 +168,13 @@ func (df DataFetcher) fetchSSO(ctx context.Context, organization string) (*OrgSS
}

url := fmt.Sprintf("orgs/%s/sso", organization)
req, err := df.client.NewRequest(http.MethodGet, url, nil)
req, err := df.client.NewRequest(ctx, http.MethodGet, url, nil)
if err != nil {
return nil, fmt.Errorf("building SSO request: %w", err)
}

var ssoResp ssoResponse
httpResp, err := df.client.Do(ctx, req, &ssoResp)
httpResp, err := df.client.Do(req, &ssoResp)
if err != nil {
if httpResp != nil && httpResp.StatusCode == http.StatusNotFound {
return &OrgSSO{Enabled: false}, nil
Expand Down Expand Up @@ -255,13 +255,13 @@ func (df DataFetcher) fetchIPAllowList(ctx context.Context, organization string)
},
}

req, err := df.client.NewRequest(http.MethodPost, "graphql", gqlQuery)
req, err := df.client.NewRequest(ctx, http.MethodPost, "graphql", gqlQuery)
if err != nil {
return nil, fmt.Errorf("building IP allow-list GraphQL request: %w", err)
}

var gqlResp graphqlResponse
_, err = df.client.Do(ctx, req, &gqlResp)
_, err = df.client.Do(req, &gqlResp)
if err != nil {
return nil, fmt.Errorf("executing IP allow-list GraphQL query: %w", err)
}
Expand Down
14 changes: 7 additions & 7 deletions internal/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"encoding/json"
"net/http"
"net/http/httptest"
"net/url"
"testing"

"github.com/google/go-github/v71/github"
"github.com/google/go-github/v93/github"
"github.com/hashicorp/go-hclog"
"github.com/open-policy-agent/opa/v1/rego"
)
Expand All @@ -17,13 +16,14 @@ func testGithubClient(t *testing.T, handler http.Handler) (*github.Client, func(
t.Helper()

server := httptest.NewServer(handler)
client := github.NewClient(server.Client())

baseURL, err := url.Parse(server.URL + "/")
baseURL := server.URL + "/"
client, err := github.NewClient(
github.WithHTTPClient(server.Client()),
github.WithURLs(&baseURL, nil),
)
if err != nil {
t.Fatalf("parsing test server URL: %v", err)
t.Fatalf("creating GitHub client: %v", err)
}
client.BaseURL = baseURL

return client, server.Close
}
Expand Down
8 changes: 6 additions & 2 deletions internal/eval_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package internal
import (
"context"
"encoding/json"
"github.com/google/go-github/v71/github"
"github.com/google/go-github/v93/github"
"github.com/hashicorp/go-hclog"
"os"
"testing"
Expand All @@ -16,9 +16,13 @@ func TestDataFetcher_FetchData(t *testing.T) {
// Simple test to locally validate that data can be fetched correctly
ctx := context.Background()

client, err := github.NewClient(github.WithAuthToken(os.Getenv("GITHUB_TOKEN")))
if err != nil {
t.Fatal(err)
}
fetcher := DataFetcher{
logger: hclog.NewNullLogger(),
client: github.NewClient(nil).WithAuthToken(os.Getenv("GITHUB_TOKEN")),
client: client,
}

org, _, err := fetcher.FetchData(ctx, "compliance-framework", false)
Expand Down
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/compliance-framework/agent/runner"
"github.com/compliance-framework/agent/runner/proto"
"github.com/compliance-framework/plugin-github-settings/internal"
"github.com/google/go-github/v71/github"
"github.com/google/go-github/v93/github"
"github.com/hashicorp/go-hclog"
goplugin "github.com/hashicorp/go-plugin"
"github.com/mitchellh/mapstructure"
Expand Down Expand Up @@ -95,7 +95,11 @@ func (l *CompliancePlugin) Configure(req *proto.ConfigureRequest) (*proto.Config
} else {
l.policyData = nil
}
l.githubClient = github.NewClient(nil).WithAuthToken(l.config.Token)
githubClient, err := github.NewClient(github.WithAuthToken(l.config.Token))
if err != nil {
return nil, fmt.Errorf("creating GitHub client: %w", err)
}
l.githubClient = githubClient
return &proto.ConfigureResponse{}, nil
}

Expand Down
Loading