- Notifications
You must be signed in to change notification settings - Fork925
feat: add backend for jfrog xray support#11829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
d6d5f7f
31fa40f
0758aea
237221e
cd8dc8b
7b41dba
22dc52e
d4f6dab
da35a46
c11cef4
02050bd
aaff98a
91d076b
c90f038
cdfeed7
55402b2
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1111,6 +1111,13 @@ func (q *querier) GetHungProvisionerJobs(ctx context.Context, hungSince time.Tim | ||
return q.db.GetHungProvisionerJobs(ctx, hungSince) | ||
} | ||
func (q *querier) GetJFrogXrayScanByWorkspaceAndAgentID(ctx context.Context, arg database.GetJFrogXrayScanByWorkspaceAndAgentIDParams) (database.JfrogXrayScan, error) { | ||
if _, err := fetch(q.log, q.auth, q.db.GetWorkspaceByID)(ctx, arg.WorkspaceID); err != nil { | ||
return database.JfrogXrayScan{}, err | ||
} | ||
return q.db.GetJFrogXrayScanByWorkspaceAndAgentID(ctx, arg) | ||
} | ||
func (q *querier) GetLastUpdateCheck(ctx context.Context) (string, error) { | ||
if err := q.authorizeContext(ctx, rbac.ActionRead, rbac.ResourceSystem); err != nil { | ||
return "", err | ||
@@ -3153,6 +3160,27 @@ func (q *querier) UpsertHealthSettings(ctx context.Context, value string) error | ||
return q.db.UpsertHealthSettings(ctx, value) | ||
} | ||
func (q *querier) UpsertJFrogXrayScanByWorkspaceAndAgentID(ctx context.Context, arg database.UpsertJFrogXrayScanByWorkspaceAndAgentIDParams) error { | ||
// TODO: Having to do all this extra querying makes me a sad panda. | ||
sreya marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
workspace, err := q.db.GetWorkspaceByID(ctx, arg.WorkspaceID) | ||
if err != nil { | ||
return xerrors.Errorf("get workspace by id: %w", err) | ||
} | ||
template, err := q.db.GetTemplateByID(ctx, workspace.TemplateID) | ||
if err != nil { | ||
return xerrors.Errorf("get template by id: %w", err) | ||
} | ||
// Only template admins should be able to write JFrog Xray scans to a workspace. | ||
// We don't want this to be a workspace-level permission because then users | ||
// could overwrite their own results. | ||
if err := q.authorizeContext(ctx, rbac.ActionCreate, template); err != nil { | ||
return err | ||
} | ||
return q.db.UpsertJFrogXrayScanByWorkspaceAndAgentID(ctx, arg) | ||
} | ||
func (q *querier) UpsertLastUpdateCheck(ctx context.Context, value string) error { | ||
if err := q.authorizeContext(ctx, rbac.ActionUpdate, rbac.ResourceSystem); err != nil { | ||
return err | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -364,7 +364,7 @@ func (s *MethodTestSuite) TestGroup() { | ||
})) | ||
} | ||
func (s *MethodTestSuite)TestProvisionerJob() { | ||
s.Run("ArchiveUnusedTemplateVersions", s.Subtest(func(db database.Store, check *expects) { | ||
j := dbgen.ProvisionerJob(s.T(), db, nil, database.ProvisionerJob{ | ||
Type: database.ProvisionerJobTypeTemplateVersionImport, | ||
@@ -2216,6 +2216,44 @@ func (s *MethodTestSuite) TestSystemFunctions() { | ||
s.Run("GetUserLinksByUserID", s.Subtest(func(db database.Store, check *expects) { | ||
check.Args(uuid.New()).Asserts(rbac.ResourceSystem, rbac.ActionRead) | ||
})) | ||
s.Run("GetJFrogXrayScanByWorkspaceAndAgentID", s.Subtest(func(db database.Store, check *expects) { | ||
ws := dbgen.Workspace(s.T(), db, database.Workspace{}) | ||
agent := dbgen.WorkspaceAgent(s.T(), db, database.WorkspaceAgent{}) | ||
err := db.UpsertJFrogXrayScanByWorkspaceAndAgentID(context.Background(), database.UpsertJFrogXrayScanByWorkspaceAndAgentIDParams{ | ||
AgentID: agent.ID, | ||
WorkspaceID: ws.ID, | ||
Critical: 1, | ||
High: 12, | ||
Medium: 14, | ||
ResultsUrl: "http://hello", | ||
}) | ||
require.NoError(s.T(), err) | ||
expect := database.JfrogXrayScan{ | ||
WorkspaceID: ws.ID, | ||
AgentID: agent.ID, | ||
Critical: 1, | ||
High: 12, | ||
Medium: 14, | ||
ResultsUrl: "http://hello", | ||
} | ||
sreya marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
check.Args(database.GetJFrogXrayScanByWorkspaceAndAgentIDParams{ | ||
WorkspaceID: ws.ID, | ||
AgentID: agent.ID, | ||
}).Asserts(ws, rbac.ActionRead).Returns(expect) | ||
})) | ||
s.Run("UpsertJFrogXrayScanByWorkspaceAndAgentID", s.Subtest(func(db database.Store, check *expects) { | ||
tpl := dbgen.Template(s.T(), db, database.Template{}) | ||
ws := dbgen.Workspace(s.T(), db, database.Workspace{ | ||
TemplateID: tpl.ID, | ||
}) | ||
check.Args(database.UpsertJFrogXrayScanByWorkspaceAndAgentIDParams{ | ||
WorkspaceID: ws.ID, | ||
AgentID: uuid.New(), | ||
}).Asserts(tpl, rbac.ActionCreate) | ||
})) | ||
} | ||
func (s *MethodTestSuite) TestOAuth2ProviderApps() { | ||
Uh oh!
There was an error while loading.Please reload this page.