Update risk matrix

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-04-15 11:16:24 -07:00
parent 7ff083e339
commit a90de1fdde
12 changed files with 771 additions and 585 deletions

View File

@@ -0,0 +1,44 @@
ALTER TABLE risks ADD COLUMN inherent_likelihood_int INTEGER;
ALTER TABLE risks ADD COLUMN inherent_impact_int INTEGER;
ALTER TABLE risks ADD COLUMN residual_likelihood_int INTEGER;
ALTER TABLE risks ADD COLUMN residual_impact_int INTEGER;
UPDATE risks SET
inherent_likelihood_int = CASE
WHEN inherent_likelihood <= 0.20 THEN 1
WHEN inherent_likelihood <= 0.40 THEN 2
WHEN inherent_likelihood <= 0.60 THEN 3
WHEN inherent_likelihood <= 0.80 THEN 4
ELSE 5
END,
inherent_impact_int = CASE
WHEN inherent_impact <= 0.20 THEN 1
WHEN inherent_impact <= 0.40 THEN 2
WHEN inherent_impact <= 0.60 THEN 3
WHEN inherent_impact <= 0.80 THEN 4
ELSE 5
END,
residual_likelihood_int = CASE
WHEN residual_likelihood <= 0.20 THEN 1
WHEN residual_likelihood <= 0.40 THEN 2
WHEN residual_likelihood <= 0.60 THEN 3
WHEN residual_likelihood <= 0.80 THEN 4
ELSE 5
END,
residual_impact_int = CASE
WHEN residual_impact <= 0.20 THEN 1
WHEN residual_impact <= 0.40 THEN 2
WHEN residual_impact <= 0.60 THEN 3
WHEN residual_impact <= 0.80 THEN 4
ELSE 5
END;
ALTER TABLE risks DROP COLUMN inherent_likelihood;
ALTER TABLE risks DROP COLUMN inherent_impact;
ALTER TABLE risks DROP COLUMN residual_likelihood;
ALTER TABLE risks DROP COLUMN residual_impact;
ALTER TABLE risks RENAME COLUMN inherent_likelihood_int TO inherent_likelihood;
ALTER TABLE risks RENAME COLUMN inherent_impact_int TO inherent_impact;
ALTER TABLE risks RENAME COLUMN residual_likelihood_int TO residual_likelihood;
ALTER TABLE risks RENAME COLUMN residual_impact_int TO residual_impact;

View File

@@ -34,10 +34,10 @@ type (
Description string `db:"description"`
Treatment RiskTreatment `db:"treatment"`
OwnerID *gid.GID `db:"owner_id"`
InherentLikelihood float64 `db:"inherent_likelihood"`
InherentImpact float64 `db:"inherent_impact"`
ResidualLikelihood float64 `db:"residual_likelihood"`
ResidualImpact float64 `db:"residual_impact"`
InherentLikelihood int `db:"inherent_likelihood"`
InherentImpact int `db:"inherent_impact"`
ResidualLikelihood int `db:"residual_likelihood"`
ResidualImpact int `db:"residual_impact"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
@@ -54,11 +54,11 @@ func (r *Risk) CursorKey(orderBy RiskOrderField) page.CursorKey {
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
}
func (r *Risk) InherentSeverity() float64 {
func (r *Risk) InherentSeverity() int {
return r.InherentLikelihood * r.InherentImpact
}
func (r *Risk) ResidualSeverity() float64 {
func (r *Risk) ResidualSeverity() int {
return r.ResidualLikelihood * r.ResidualImpact
}

View File

@@ -36,10 +36,10 @@ type (
Description string
Treatment coredata.RiskTreatment
OwnerID *gid.GID
InherentLikelihood float64
InherentImpact float64
ResidualLikelihood *float64
ResidualImpact *float64
InherentLikelihood int
InherentImpact int
ResidualLikelihood *int
ResidualImpact *int
}
UpdateRiskRequest struct {
@@ -48,10 +48,10 @@ type (
Description *string
Treatment *coredata.RiskTreatment
OwnerID *gid.GID
InherentLikelihood *float64
InherentImpact *float64
ResidualLikelihood *float64
ResidualImpact *float64
InherentLikelihood *int
InherentImpact *int
ResidualLikelihood *int
ResidualImpact *int
}
)

View File

@@ -628,12 +628,12 @@ type Risk implements Node {
name: String!
description: String!
treatment: RiskTreatment!
inherentLikelihood: Float!
inherentImpact: Float!
inherentSeverity: Float!
residualLikelihood: Float!
residualImpact: Float!
residualSeverity: Float!
inherentLikelihood: Int!
inherentImpact: Int!
inherentSeverity: Int!
residualLikelihood: Int!
residualImpact: Int!
residualSeverity: Int!
owner: People @goField(forceResolver: true)
@@ -1092,10 +1092,10 @@ input CreateRiskInput {
description: String!
ownerId: ID
treatment: RiskTreatment!
inherentLikelihood: Float!
inherentImpact: Float!
residualLikelihood: Float
residualImpact: Float
inherentLikelihood: Int!
inherentImpact: Int!
residualLikelihood: Int
residualImpact: Int
}
input UpdateRiskInput {
@@ -1104,10 +1104,10 @@ input UpdateRiskInput {
description: String
ownerId: ID
treatment: RiskTreatment
inherentLikelihood: Float
inherentImpact: Float
residualLikelihood: Float
residualImpact: Float
inherentLikelihood: Int
inherentImpact: Int
residualLikelihood: Int
residualImpact: Int
}
input DeleteRiskInput {

View File

@@ -3739,12 +3739,12 @@ type Risk implements Node {
name: String!
description: String!
treatment: RiskTreatment!
inherentLikelihood: Float!
inherentImpact: Float!
inherentSeverity: Float!
residualLikelihood: Float!
residualImpact: Float!
residualSeverity: Float!
inherentLikelihood: Int!
inherentImpact: Int!
inherentSeverity: Int!
residualLikelihood: Int!
residualImpact: Int!
residualSeverity: Int!
owner: People @goField(forceResolver: true)
@@ -4203,10 +4203,10 @@ input CreateRiskInput {
description: String!
ownerId: ID
treatment: RiskTreatment!
inherentLikelihood: Float!
inherentImpact: Float!
residualLikelihood: Float
residualImpact: Float
inherentLikelihood: Int!
inherentImpact: Int!
residualLikelihood: Int
residualImpact: Int
}
input UpdateRiskInput {
@@ -4215,10 +4215,10 @@ input UpdateRiskInput {
description: String
ownerId: ID
treatment: RiskTreatment
inherentLikelihood: Float
inherentImpact: Float
residualLikelihood: Float
residualImpact: Float
inherentLikelihood: Int
inherentImpact: Int
residualLikelihood: Int
residualImpact: Int
}
input DeleteRiskInput {
@@ -16907,9 +16907,9 @@ func (ec *executionContext) _Risk_inherentLikelihood(ctx context.Context, field
}
return graphql.Null
}
res := resTmp.(float64)
res := resTmp.(int)
fc.Result = res
return ec.marshalNFloat2float64(ctx, field.Selections, res)
return ec.marshalNInt2int(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Risk_inherentLikelihood(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
@@ -16919,7 +16919,7 @@ func (ec *executionContext) fieldContext_Risk_inherentLikelihood(_ context.Conte
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Float does not have child fields")
return nil, errors.New("field of type Int does not have child fields")
},
}
return fc, nil
@@ -16951,9 +16951,9 @@ func (ec *executionContext) _Risk_inherentImpact(ctx context.Context, field grap
}
return graphql.Null
}
res := resTmp.(float64)
res := resTmp.(int)
fc.Result = res
return ec.marshalNFloat2float64(ctx, field.Selections, res)
return ec.marshalNInt2int(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Risk_inherentImpact(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
@@ -16963,7 +16963,7 @@ func (ec *executionContext) fieldContext_Risk_inherentImpact(_ context.Context,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Float does not have child fields")
return nil, errors.New("field of type Int does not have child fields")
},
}
return fc, nil
@@ -16995,9 +16995,9 @@ func (ec *executionContext) _Risk_inherentSeverity(ctx context.Context, field gr
}
return graphql.Null
}
res := resTmp.(float64)
res := resTmp.(int)
fc.Result = res
return ec.marshalNFloat2float64(ctx, field.Selections, res)
return ec.marshalNInt2int(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Risk_inherentSeverity(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
@@ -17007,7 +17007,7 @@ func (ec *executionContext) fieldContext_Risk_inherentSeverity(_ context.Context
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Float does not have child fields")
return nil, errors.New("field of type Int does not have child fields")
},
}
return fc, nil
@@ -17039,9 +17039,9 @@ func (ec *executionContext) _Risk_residualLikelihood(ctx context.Context, field
}
return graphql.Null
}
res := resTmp.(float64)
res := resTmp.(int)
fc.Result = res
return ec.marshalNFloat2float64(ctx, field.Selections, res)
return ec.marshalNInt2int(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Risk_residualLikelihood(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
@@ -17051,7 +17051,7 @@ func (ec *executionContext) fieldContext_Risk_residualLikelihood(_ context.Conte
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Float does not have child fields")
return nil, errors.New("field of type Int does not have child fields")
},
}
return fc, nil
@@ -17083,9 +17083,9 @@ func (ec *executionContext) _Risk_residualImpact(ctx context.Context, field grap
}
return graphql.Null
}
res := resTmp.(float64)
res := resTmp.(int)
fc.Result = res
return ec.marshalNFloat2float64(ctx, field.Selections, res)
return ec.marshalNInt2int(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Risk_residualImpact(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
@@ -17095,7 +17095,7 @@ func (ec *executionContext) fieldContext_Risk_residualImpact(_ context.Context,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Float does not have child fields")
return nil, errors.New("field of type Int does not have child fields")
},
}
return fc, nil
@@ -17127,9 +17127,9 @@ func (ec *executionContext) _Risk_residualSeverity(ctx context.Context, field gr
}
return graphql.Null
}
res := resTmp.(float64)
res := resTmp.(int)
fc.Result = res
return ec.marshalNFloat2float64(ctx, field.Selections, res)
return ec.marshalNInt2int(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Risk_residualSeverity(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
@@ -17139,7 +17139,7 @@ func (ec *executionContext) fieldContext_Risk_residualSeverity(_ context.Context
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Float does not have child fields")
return nil, errors.New("field of type Int does not have child fields")
},
}
return fc, nil
@@ -24054,28 +24054,28 @@ func (ec *executionContext) unmarshalInputCreateRiskInput(ctx context.Context, o
it.Treatment = data
case "inherentLikelihood":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inherentLikelihood"))
data, err := ec.unmarshalNFloat2float64(ctx, v)
data, err := ec.unmarshalNInt2int(ctx, v)
if err != nil {
return it, err
}
it.InherentLikelihood = data
case "inherentImpact":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inherentImpact"))
data, err := ec.unmarshalNFloat2float64(ctx, v)
data, err := ec.unmarshalNInt2int(ctx, v)
if err != nil {
return it, err
}
it.InherentImpact = data
case "residualLikelihood":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("residualLikelihood"))
data, err := ec.unmarshalOFloat2ᚖfloat64(ctx, v)
data, err := ec.unmarshalOInt2ᚖint(ctx, v)
if err != nil {
return it, err
}
it.ResidualLikelihood = data
case "residualImpact":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("residualImpact"))
data, err := ec.unmarshalOFloat2ᚖfloat64(ctx, v)
data, err := ec.unmarshalOInt2ᚖint(ctx, v)
if err != nil {
return it, err
}
@@ -25605,28 +25605,28 @@ func (ec *executionContext) unmarshalInputUpdateRiskInput(ctx context.Context, o
it.Treatment = data
case "inherentLikelihood":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inherentLikelihood"))
data, err := ec.unmarshalOFloat2ᚖfloat64(ctx, v)
data, err := ec.unmarshalOInt2ᚖint(ctx, v)
if err != nil {
return it, err
}
it.InherentLikelihood = data
case "inherentImpact":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inherentImpact"))
data, err := ec.unmarshalOFloat2ᚖfloat64(ctx, v)
data, err := ec.unmarshalOInt2ᚖint(ctx, v)
if err != nil {
return it, err
}
it.InherentImpact = data
case "residualLikelihood":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("residualLikelihood"))
data, err := ec.unmarshalOFloat2ᚖfloat64(ctx, v)
data, err := ec.unmarshalOInt2ᚖint(ctx, v)
if err != nil {
return it, err
}
it.ResidualLikelihood = data
case "residualImpact":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("residualImpact"))
data, err := ec.unmarshalOFloat2ᚖfloat64(ctx, v)
data, err := ec.unmarshalOInt2ᚖint(ctx, v)
if err != nil {
return it, err
}
@@ -32508,21 +32508,6 @@ var (
}
)
func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v any) (float64, error) {
res, err := graphql.UnmarshalFloatContext(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler {
res := graphql.MarshalFloatContext(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
}
}
return graphql.WrapContextMarshaler(ctx, res)
}
func (ec *executionContext) marshalNFramework2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐFramework(ctx context.Context, sel ast.SelectionSet, v *types.Framework) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
@@ -34555,22 +34540,6 @@ func (ec *executionContext) unmarshalOEvidenceOrder2ᚖgithubᚗcomᚋgetprobo
return &res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) unmarshalOFloat2ᚖfloat64(ctx context.Context, v any) (*float64, error) {
if v == nil {
return nil, nil
}
res, err := graphql.UnmarshalFloatContext(ctx, v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalOFloat2ᚖfloat64(ctx context.Context, sel ast.SelectionSet, v *float64) graphql.Marshaler {
if v == nil {
return graphql.Null
}
res := graphql.MarshalFloatContext(*v)
return graphql.WrapContextMarshaler(ctx, res)
}
func (ec *executionContext) unmarshalOFrameworkOrder2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐFrameworkOrderBy(ctx context.Context, v any) (*types.FrameworkOrderBy, error) {
if v == nil {
return nil, nil

View File

@@ -152,10 +152,10 @@ type CreateRiskInput struct {
Description string `json:"description"`
OwnerID *gid.GID `json:"ownerId,omitempty"`
Treatment coredata.RiskTreatment `json:"treatment"`
InherentLikelihood float64 `json:"inherentLikelihood"`
InherentImpact float64 `json:"inherentImpact"`
ResidualLikelihood *float64 `json:"residualLikelihood,omitempty"`
ResidualImpact *float64 `json:"residualImpact,omitempty"`
InherentLikelihood int `json:"inherentLikelihood"`
InherentImpact int `json:"inherentImpact"`
ResidualLikelihood *int `json:"residualLikelihood,omitempty"`
ResidualImpact *int `json:"residualImpact,omitempty"`
}
type CreateRiskMesureMappingInput struct {
@@ -562,12 +562,12 @@ type Risk struct {
Name string `json:"name"`
Description string `json:"description"`
Treatment coredata.RiskTreatment `json:"treatment"`
InherentLikelihood float64 `json:"inherentLikelihood"`
InherentImpact float64 `json:"inherentImpact"`
InherentSeverity float64 `json:"inherentSeverity"`
ResidualLikelihood float64 `json:"residualLikelihood"`
ResidualImpact float64 `json:"residualImpact"`
ResidualSeverity float64 `json:"residualSeverity"`
InherentLikelihood int `json:"inherentLikelihood"`
InherentImpact int `json:"inherentImpact"`
InherentSeverity int `json:"inherentSeverity"`
ResidualLikelihood int `json:"residualLikelihood"`
ResidualImpact int `json:"residualImpact"`
ResidualSeverity int `json:"residualSeverity"`
Owner *People `json:"owner,omitempty"`
Mesures *MesureConnection `json:"mesures"`
Policies *PolicyConnection `json:"policies"`
@@ -691,10 +691,10 @@ type UpdateRiskInput struct {
Description *string `json:"description,omitempty"`
OwnerID *gid.GID `json:"ownerId,omitempty"`
Treatment *coredata.RiskTreatment `json:"treatment,omitempty"`
InherentLikelihood *float64 `json:"inherentLikelihood,omitempty"`
InherentImpact *float64 `json:"inherentImpact,omitempty"`
ResidualLikelihood *float64 `json:"residualLikelihood,omitempty"`
ResidualImpact *float64 `json:"residualImpact,omitempty"`
InherentLikelihood *int `json:"inherentLikelihood,omitempty"`
InherentImpact *int `json:"inherentImpact,omitempty"`
ResidualLikelihood *int `json:"residualLikelihood,omitempty"`
ResidualImpact *int `json:"residualImpact,omitempty"`
}
type UpdateRiskPayload struct {