Skip to content

Commit

Permalink
GraphQL - Expose client queries (#1941)
Browse files Browse the repository at this point in the history
* expose artifact and builder query

Signed-off-by: pxp928 <parth.psu@gmail.com>

* add certifybad, certifygood query

Signed-off-by: pxp928 <parth.psu@gmail.com>

* add certifylegal client query

Signed-off-by: pxp928 <parth.psu@gmail.com>

* add certifyscorecard and vex client query

Signed-off-by: pxp928 <parth.psu@gmail.com>

* add point of contact and hashEqual client query

Signed-off-by: pxp928 <parth.psu@gmail.com>

* add hasSourceAt and isDep client query

Signed-off-by: pxp928 <parth.psu@gmail.com>

* add occur and license client query

Signed-off-by: pxp928 <parth.psu@gmail.com>

* add hasMetadata client query

Signed-off-by: pxp928 <parth.psu@gmail.com>

* add pkgEqual. vulnEqual and vulnMetadata client query

Signed-off-by: pxp928 <parth.psu@gmail.com>

* fix naming for client query

Signed-off-by: pxp928 <parth.psu@gmail.com>

* update pull request template to add graphQL client check

Signed-off-by: pxp928 <parth.psu@gmail.com>

---------

Signed-off-by: pxp928 <parth.psu@gmail.com>
  • Loading branch information
pxp928 authored Jun 4, 2024
1 parent e3e0f93 commit 089496d
Show file tree
Hide file tree
Showing 21 changed files with 24,047 additions and 16,285 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [ ] All commits have [a Developer Certificate of Origin (DCO)](https://wiki.linuxfoundation.org/dco) -- they are generated using `-s` flag to `git commit`.
- [ ] All new changes are covered by tests
- [ ] If GraphQL schema is changed, `make generate` has been run
- [ ] If GraphQL schema is changed, GraphQL client updates/additions have been made
- [ ] If OpenAPI spec is changed, `make generate` has been run
- [ ] If `collectsub` protobuf has been changed, `make proto` has been run
- [ ] All CI checks are passing (tests and formatting)
Expand Down
4 changes: 2 additions & 2 deletions cmd/guacone/cmd/bad.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ var queryBadCmd = &cobra.Command{
httpClient := http.Client{Transport: cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport)}
gqlclient := graphql.NewClient(opts.graphqlEndpoint, &httpClient)

certifyBadResponse, err := model.CertifyBads(ctx, gqlclient, model.CertifyBadSpec{})
certifyBadResponse, err := model.CertifyBad(ctx, gqlclient, model.CertifyBadSpec{})
if err != nil {
logger.Fatalf("error querying for package: %v", err)
}

mapCertifyBad := map[string][]model.CertifyBadsCertifyBad{}
mapCertifyBad := map[string][]model.CertifyBadCertifyBad{}
for _, certifyBad := range certifyBadResponse.CertifyBad {
switch subject := certifyBad.Subject.(type) {
case *model.AllCertifyBadSubjectPackage:
Expand Down
39,928 changes: 23,660 additions & 16,268 deletions pkg/assembler/clients/generated/operations.go

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions pkg/assembler/clients/operations/artifact.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,20 @@ query Artifacts($filter: ArtifactSpec!) {
...AllArtifactTree
}
}

query ArtifactsList($filter: ArtifactSpec!, $after: ID, $first: Int) {
artifactsList(artifactSpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllArtifactTree
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}
26 changes: 26 additions & 0 deletions pkg/assembler/clients/operations/builder.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,29 @@ mutation IngestBuilder($builder: IDorBuilderInput!) {
mutation IngestBuilders($builders: [IDorBuilderInput!]!) {
ingestBuilders(builders: $builders)
}


# Exposes GraphQL queries to retrieve GUAC builders

query Builders($filter: BuilderSpec!) {
builders(builderSpec: $filter) {
...AllBuilderTree
}
}

query BuildersList($filter: BuilderSpec!, $after: ID, $first: Int) {
buildersList(builderSpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllBuilderTree
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}
19 changes: 18 additions & 1 deletion pkg/assembler/clients/operations/certifyBad.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,25 @@ mutation IngestCertifyBadArtifacts(

# Exposes GraphQL queries to retrieve GUAC CertifyBads

query CertifyBads($filter: CertifyBadSpec!) {
query CertifyBad($filter: CertifyBadSpec!) {
CertifyBad(certifyBadSpec: $filter) {
...AllCertifyBad
}
}

query CertifyBadList($filter: CertifyBadSpec!, $after: ID, $first: Int) {
CertifyBadList(certifyBadSpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllCertifyBad
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}
25 changes: 25 additions & 0 deletions pkg/assembler/clients/operations/certifyGood.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,28 @@ mutation IngestCertifyGoodArtifacts(
certifyGoods: $certifyGoods
)
}

# Exposes GraphQL queries to retrieve GUAC CertifyGood

query CertifyGood($filter: CertifyGoodSpec!) {
CertifyGood(certifyGoodSpec: $filter) {
...AllCertifyGood
}
}

query CertifyGoodList($filter: CertifyGoodSpec!, $after: ID, $first: Int) {
CertifyGoodList(certifyGoodSpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllCertifyGood
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}
21 changes: 20 additions & 1 deletion pkg/assembler/clients/operations/certifyLegal.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,27 @@ mutation IngestCertifyLegalSrcs($srcs: [IDorSourceInput!]!, $declaredLicensesLis
ingestCertifyLegals(subjects: {sources: $srcs}, declaredLicensesList: $declaredLicensesList, discoveredLicensesList: $discoveredLicensesList, certifyLegals: $legals)
}

query CertifyLegals($filter: CertifyLegalSpec!) {
# Exposes GraphQL queries to retrieve GUAC CertifyLegal

query CertifyLegal($filter: CertifyLegalSpec!) {
CertifyLegal(certifyLegalSpec: $filter) {
...AllCertifyLegalTree
}
}

query CertifyLegalList($filter: CertifyLegalSpec!, $after: ID, $first: Int) {
CertifyLegalList(certifyLegalSpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllCertifyLegalTree
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}
19 changes: 19 additions & 0 deletions pkg/assembler/clients/operations/certifyScorecard.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,27 @@ mutation IngestCertifyScorecards(
ingestScorecards(sources: $sources, scorecards: $scorecards)
}

# Exposes GraphQL queries to retrieve GUAC Scorecards

query Scorecards($filter: CertifyScorecardSpec!) {
scorecards(scorecardSpec: $filter) {
...AllCertifyScorecard
}
}

query ScorecardsList($filter: CertifyScorecardSpec!, $after: ID, $first: Int) {
scorecardsList(scorecardSpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllCertifyScorecard
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}
24 changes: 24 additions & 0 deletions pkg/assembler/clients/operations/certifyVEXStatement.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,27 @@ mutation IngestCertifyVexArtifacts(
vexStatements: $vexStatements)
}

# Exposes GraphQL queries to retrieve GUAC VEX

query VEXStatements($filter: CertifyVEXStatementSpec!) {
CertifyVEXStatement(certifyVEXStatementSpec: $filter) {
...AllCertifyVEXStatement
}
}

query VEXStatementList($filter: CertifyVEXStatementSpec!, $after: ID, $first: Int) {
CertifyVEXStatementList(certifyVEXStatementSpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllCertifyVEXStatement
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}
25 changes: 25 additions & 0 deletions pkg/assembler/clients/operations/contact.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,28 @@ mutation IngestPointOfContactArtifacts(
pointOfContacts: $pointOfContacts
)
}

# Exposes GraphQL queries to retrieve GUAC Point of Contact

query PointOfContacts($filter: PointOfContactSpec!) {
PointOfContact(pointOfContactSpec: $filter) {
...AllPointOfContact
}
}

query PointOfContactList($filter: PointOfContactSpec!, $after: ID, $first: Int) {
PointOfContactList(pointOfContactSpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllPointOfContact
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}
25 changes: 25 additions & 0 deletions pkg/assembler/clients/operations/hasSourceAt.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,28 @@ mutation IngestHasSourcesAt(
hasSourceAts: $hasSourceAts
)
}

# Exposes GraphQL queries to retrieve GUAC HasSourceAt

query HasSourceAt($filter: HasSourceAtSpec!) {
HasSourceAt(hasSourceAtSpec: $filter) {
...AllHasSourceAt
}
}

query HasSourceAtList($filter: HasSourceAtSpec!, $after: ID, $first: Int) {
HasSourceAtList(hasSourceAtSpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllHasSourceAt
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}
31 changes: 25 additions & 6 deletions pkg/assembler/clients/operations/hashEqual.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@

# NOTE: This is experimental and might change in the future!

query HashEquals($filter: HashEqualSpec!) {
HashEqual(hashEqualSpec: $filter) {
...AllHashEqualTree
}
}

# Defines the GraphQL operations to certify that two artifacts are identical

mutation IngestHashEqual(
Expand Down Expand Up @@ -48,3 +42,28 @@ mutation IngestHashEquals(
hashEquals: $hashEquals
)
}

# Exposes GraphQL queries to retrieve GUAC HashEqual

query HashEquals($filter: HashEqualSpec!) {
HashEqual(hashEqualSpec: $filter) {
...AllHashEqualTree
}
}

query HashEqualList($filter: HashEqualSpec!, $after: ID, $first: Int) {
HashEqualList(hashEqualSpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllHashEqualTree
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}
17 changes: 17 additions & 0 deletions pkg/assembler/clients/operations/isDependency.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,20 @@ query Dependencies($filter: IsDependencySpec!) {
...AllIsDependencyTree
}
}

query DependencyList($filter: IsDependencySpec!, $after: ID, $first: Int) {
IsDependencyList(isDependencySpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllIsDependencyTree
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}
32 changes: 26 additions & 6 deletions pkg/assembler/clients/operations/isOccurrence.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@

# Defines the GraphQL operations to ingest occurrence information into GUAC

query IsOccurrences($filter: IsOccurrenceSpec!) {
IsOccurrence(isOccurrenceSpec: $filter) {
...AllIsOccurrencesTree
}
}

mutation IngestIsOccurrencePkg(
$pkg: IDorPkgInput!
$artifact: IDorArtifactInput!
Expand Down Expand Up @@ -72,3 +66,29 @@ mutation IngestIsOccurrencesSrc(
occurrences: $occurrences
)
}

# Exposes GraphQL queries to retrieve IsOccurrences

query Occurrences($filter: IsOccurrenceSpec!) {
IsOccurrence(isOccurrenceSpec: $filter) {
...AllIsOccurrencesTree
}
}

query OccurrenceList($filter: IsOccurrenceSpec!, $after: ID, $first: Int) {
IsOccurrenceList(isOccurrenceSpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllIsOccurrencesTree
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}

17 changes: 17 additions & 0 deletions pkg/assembler/clients/operations/license.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,20 @@ query Licenses($filter: LicenseSpec!) {
...AllLicenseTree
}
}

query LicenseList($filter: LicenseSpec!, $after: ID, $first: Int) {
licenseList(licenseSpec: $filter, after: $after, first: $first) {
totalCount
edges {
cursor
node {
...AllLicenseTree
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}
Loading

0 comments on commit 089496d

Please sign in to comment.