@@ -67,15 +67,13 @@ enum TaskState
|
||||
|
||||
enum EvidenceState
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.EvidenceState") {
|
||||
VALID
|
||||
@goEnum(value: "github.com/getprobo/probo/pkg/coredata.EvidenceStateValid")
|
||||
INVALID
|
||||
FULFILLED
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.EvidenceStateInvalid"
|
||||
value: "github.com/getprobo/probo/pkg/coredata.EvidenceStateFulfilled"
|
||||
)
|
||||
EXPIRED
|
||||
REQUESTED
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.EvidenceStateExpired"
|
||||
value: "github.com/getprobo/probo/pkg/coredata.EvidenceStateRequested"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -751,7 +749,9 @@ type Mutation {
|
||||
deleteRiskMapping(input: DeleteRiskMappingInput!): DeleteRiskMappingPayload!
|
||||
|
||||
# Evidence mutations
|
||||
uploadEvidence(input: UploadEvidenceInput!): UploadEvidencePayload!
|
||||
requestEvidence(input: RequestEvidenceInput!): RequestEvidencePayload!
|
||||
fulfillEvidence(input: FulfillEvidenceInput!): FulfillEvidencePayload!
|
||||
createEvidence(input: CreateEvidenceInput!): CreateEvidencePayload!
|
||||
deleteEvidence(input: DeleteEvidenceInput!): DeleteEvidencePayload!
|
||||
|
||||
# Policy mutations
|
||||
@@ -939,12 +939,25 @@ input DeleteRiskMappingInput {
|
||||
mitigationId: ID!
|
||||
}
|
||||
|
||||
input UploadEvidenceInput {
|
||||
input RequestEvidenceInput {
|
||||
taskId: ID!
|
||||
name: String!
|
||||
type: EvidenceType!
|
||||
description: String!
|
||||
}
|
||||
|
||||
input FulfillEvidenceInput {
|
||||
evidenceId: ID!
|
||||
file: Upload
|
||||
url: String
|
||||
}
|
||||
|
||||
input CreateEvidenceInput {
|
||||
taskId: ID!
|
||||
name: String!
|
||||
type: EvidenceType!
|
||||
url: String
|
||||
file: Upload
|
||||
description: String!
|
||||
}
|
||||
|
||||
@@ -1102,7 +1115,15 @@ type DeleteRiskMappingPayload {
|
||||
success: Boolean!
|
||||
}
|
||||
|
||||
type UploadEvidencePayload {
|
||||
type RequestEvidencePayload {
|
||||
evidenceEdge: EvidenceEdge!
|
||||
}
|
||||
|
||||
type FulfillEvidencePayload {
|
||||
evidenceEdge: EvidenceEdge!
|
||||
}
|
||||
|
||||
type CreateEvidencePayload {
|
||||
evidenceEdge: EvidenceEdge!
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -68,6 +68,19 @@ type CreateControlMappingPayload struct {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
type CreateEvidenceInput struct {
|
||||
TaskID gid.GID `json:"taskId"`
|
||||
Name string `json:"name"`
|
||||
Type coredata.EvidenceType `json:"type"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
File *graphql.Upload `json:"file,omitempty"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type CreateEvidencePayload struct {
|
||||
EvidenceEdge *EvidenceEdge `json:"evidenceEdge"`
|
||||
}
|
||||
|
||||
type CreateFrameworkInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Name string `json:"name"`
|
||||
@@ -306,6 +319,16 @@ type FrameworkEdge struct {
|
||||
Node *Framework `json:"node"`
|
||||
}
|
||||
|
||||
type FulfillEvidenceInput struct {
|
||||
EvidenceID gid.GID `json:"evidenceId"`
|
||||
File *graphql.Upload `json:"file,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
type FulfillEvidencePayload struct {
|
||||
EvidenceEdge *EvidenceEdge `json:"evidenceEdge"`
|
||||
}
|
||||
|
||||
type ImportFrameworkInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
File graphql.Upload `json:"file"`
|
||||
@@ -463,6 +486,17 @@ type RemoveUserPayload struct {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
type RequestEvidenceInput struct {
|
||||
TaskID gid.GID `json:"taskId"`
|
||||
Name string `json:"name"`
|
||||
Type coredata.EvidenceType `json:"type"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type RequestEvidencePayload struct {
|
||||
EvidenceEdge *EvidenceEdge `json:"evidenceEdge"`
|
||||
}
|
||||
|
||||
type Risk struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
@@ -624,19 +658,6 @@ type UpdateVendorPayload struct {
|
||||
Vendor *Vendor `json:"vendor"`
|
||||
}
|
||||
|
||||
type UploadEvidenceInput struct {
|
||||
TaskID gid.GID `json:"taskId"`
|
||||
Name string `json:"name"`
|
||||
File *graphql.Upload `json:"file,omitempty"`
|
||||
Type coredata.EvidenceType `json:"type"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type UploadEvidencePayload struct {
|
||||
EvidenceEdge *EvidenceEdge `json:"evidenceEdge"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID gid.GID `json:"id"`
|
||||
FullName string `json:"fullName"`
|
||||
|
||||
@@ -718,20 +718,62 @@ func (r *mutationResolver) DeleteRiskMapping(ctx context.Context, input types.De
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UploadEvidence is the resolver for the uploadEvidence field.
|
||||
func (r *mutationResolver) UploadEvidence(ctx context.Context, input types.UploadEvidenceInput) (*types.UploadEvidencePayload, error) {
|
||||
// RequestEvidence is the resolver for the requestEvidence field.
|
||||
func (r *mutationResolver) RequestEvidence(ctx context.Context, input types.RequestEvidenceInput) (*types.RequestEvidencePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.TaskID.TenantID())
|
||||
|
||||
var url string
|
||||
if input.URL != nil {
|
||||
url = *input.URL
|
||||
evidence, err := svc.Evidences.Request(
|
||||
ctx,
|
||||
probo.RequestEvidenceRequest{
|
||||
TaskID: input.TaskID,
|
||||
Name: input.Name,
|
||||
Type: input.Type,
|
||||
Description: input.Description,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot request evidence: %w", err))
|
||||
}
|
||||
|
||||
return &types.RequestEvidencePayload{
|
||||
EvidenceEdge: types.NewEvidenceEdge(evidence, coredata.EvidenceOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// FulfillEvidence is the resolver for the fulfillEvidence field.
|
||||
func (r *mutationResolver) FulfillEvidence(ctx context.Context, input types.FulfillEvidenceInput) (*types.FulfillEvidencePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.EvidenceID.TenantID())
|
||||
|
||||
req := probo.FulfilledEvidenceRequest{
|
||||
EvidenceID: input.EvidenceID,
|
||||
}
|
||||
|
||||
if input.File != nil {
|
||||
req.File = input.File.File
|
||||
}
|
||||
|
||||
if input.URL != nil {
|
||||
req.URL = *input.URL
|
||||
}
|
||||
|
||||
evidence, err := svc.Evidences.Fulfill(ctx, req)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot fulfill evidence: %w", err))
|
||||
}
|
||||
|
||||
return &types.FulfillEvidencePayload{
|
||||
EvidenceEdge: types.NewEvidenceEdge(evidence, coredata.EvidenceOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateEvidence is the resolver for the createEvidence field.
|
||||
func (r *mutationResolver) CreateEvidence(ctx context.Context, input types.CreateEvidenceInput) (*types.CreateEvidencePayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.TaskID.TenantID())
|
||||
|
||||
req := probo.CreateEvidenceRequest{
|
||||
TaskID: input.TaskID,
|
||||
Name: input.Name,
|
||||
Type: input.Type,
|
||||
URL: url,
|
||||
Description: input.Description,
|
||||
}
|
||||
|
||||
@@ -751,7 +793,7 @@ func (r *mutationResolver) UploadEvidence(ctx context.Context, input types.Uploa
|
||||
panic(fmt.Errorf("failed to create evidence: %w", err))
|
||||
}
|
||||
|
||||
return &types.UploadEvidencePayload{
|
||||
return &types.CreateEvidencePayload{
|
||||
EvidenceEdge: types.NewEvidenceEdge(evidence, coredata.EvidenceOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user