Skip to content

Commit

Permalink
Upgrade aug v2 (#9)
Browse files Browse the repository at this point in the history
* required files created

* func added to transition into new jira schema

* jira translation done

* not needed file removed

* schema and folder added

* files altered

* scoring function

* scoring func updated in sync with ssd opa

* log messages added

* fix: logs & continue/return stats

* fix: artifact risk id query

---------

Co-authored-by: priyanshishikha <[email protected]>
  • Loading branch information
genos1998 and priyanshishikha authored Sep 18, 2024
1 parent 41bc9ae commit d1d9f22
Show file tree
Hide file tree
Showing 15 changed files with 7,483 additions and 20 deletions.
17 changes: 17 additions & 0 deletions august2024august2024v2/genqlient.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
schema: schema.graphql
operations:
- queries.graphql
generated: schema-generated.go
package: august2024august2024v2
use_struct_references: true
bindings:
Boolean:
type: "*bool"
DateTime:
type: "*time.Time"
Int64:
type: int64
Int:
type: "*int"
ID:
type: "*string"
60 changes: 60 additions & 0 deletions august2024august2024v2/modules.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package august2024august2024v2

import "time"

const (
RunHistoryStatusException = "exception"

Pass string = "pass"
Fail string = "fail"
Low string = "low"
Medium string = "medium"
High string = "high"
Critical string = "critical"

SOURCE string = "source"
BUILD string = "build"
ARTIFACT string = "artifact"
DEPLOY string = "deploy"
ImageRisk string = "imageRisk"

HighStatusValue int = 50
LowStatusValue int = 70
)

type Scoring struct {
OrganizationName string
TeamName string
Namespace string
ClusterId string
ApplicationName string
ServiceName string
DeployedAt time.Time
Policy map[string][]PolicyDetail
Image string
ImageTag string
ImageSha string
ApplicationDeploymentId string
BlockedDeployment bool
FailDeploymentFirewallResult bool
DeploymentFirewall bool
}

type PolicyDetail struct {
PolicyName string
Stage string
Status string
Severity string
}

type PolicyStatusCount struct {
PassCount int
LowPassCount int
MediumPassCount int
HighPassCount int
CriticalPassCount int
LowCount int
MediumCount int
HighCount int
CriticalCount int
}
107 changes: 107 additions & 0 deletions august2024august2024v2/queries.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
query GetArtifactScanDataId {
queryArtifactScanData {
id
artifactRisk {
id
}
}
}

query QueryArtifactScanDataRunHistory ($scanDataId: String!) {
queryArtifactScanData(filter: {id:{eq:$scanDataId}}) @cascade(fields: ["artifactRunHistory"]) {
artifactRunHistory @cascade(fields: ["id"]) {
id
policyId
PolicyName
Stage
Artifact
ArtifactTag
ArtifactSha
CreatedAt
UpdatedAt
DeployedAt
Hash
Pass
MetaData
scheduledPolicy
DatasourceTool
Status
securityIssue {
AlertTitle
AlertMessage
Suggestions
Severity
Action
Error
}
policyEnforcements {
id
status
severity
action
conditionValue
policy {
id
policyName
category
stage
scheduledPolicy
script
variables
conditionName
suggestion
}
}
}
}
}

query GetArtifactRisk($id: ID!) {
getArtifactRisk(id: $id) {
sourceCodeAlertsScore
buildAlertsScore
artifactAlertsScore
deploymentAlertsScore
artifactRiskStatus
}
}

mutation UpdateArtifactScanDataRiskScoreAndStatus(
$id: ID!
$riskStatus: RiskStatus!
$buildAlertsScore: Int
$sourceCodeAlertsScore: Int
$artifactAlertsScore: Int
$deploymentAlertsScore: Int
) {
updateArtifactRisk(
input: {
set: {
artifactRiskStatus: $riskStatus
sourceCodeAlertsScore: $sourceCodeAlertsScore
buildAlertsScore: $buildAlertsScore
artifactAlertsScore: $artifactAlertsScore
deploymentAlertsScore: $deploymentAlertsScore
}
filter: { id: [$id] }
}
) {
numUids
}
}


mutation UpdateArtifactScanData($artifactScanDataId: String!) {
updateArtifactScanData(
input: {
set: { artifactRisk: { artifactRiskStatus: scanning } }
filter: { id: { eq: $artifactScanDataId } }
}
) {
artifactScanData {
artifactRisk {
id
}
}
}
}
Loading

0 comments on commit d1d9f22

Please sign in to comment.