Skip to content

Commit

Permalink
Add search gql (#998)
Browse files Browse the repository at this point in the history
* add findSoftware graphql schema

Signed-off-by: Brandon Lum <lumjjb@gmail.com>

* add findSoftware client operations

Signed-off-by: Brandon Lum <lumjjb@gmail.com>

* graphql server plumbing not implemented

Signed-off-by: Brandon Lum <lumjjb@gmail.com>

* update copyright exclusion with new files

Signed-off-by: Brandon Lum <lumjjb@gmail.com>

---------

Signed-off-by: Brandon Lum <lumjjb@gmail.com>
  • Loading branch information
lumjjb committed Jun 29, 2023
1 parent f3cbf4c commit d29cbb8
Show file tree
Hide file tree
Showing 11 changed files with 879 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/scripts/excluded_from_copyright
Expand Up @@ -46,6 +46,7 @@
./pkg/assembler/graphql/resolvers/isVulnerability.resolvers.go
./pkg/assembler/graphql/generated/certifyVEXStatement.generated.go
./pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers.go
./pkg/assembler/graphql/resolvers/search.resolvers.go
./pkg/assembler/graphql/resolvers/path.resolvers.go
./pkg/assembler/graphql/generated/path.generated.go
./internal/testing/mocks/scorecard.go
Expand Down
3 changes: 3 additions & 0 deletions pkg/assembler/backends/backends.go
Expand Up @@ -79,6 +79,9 @@ type Backend interface {
Node(ctx context.Context, node string) (model.Node, error)
Nodes(ctx context.Context, nodes []string) ([]model.Node, error)
Path(ctx context.Context, subject string, target string, maxPathLength int, usingOnly []model.Edge) ([]model.Node, error)

// Search queries: queries to help find data in GUAC based on text search
FindSoftware(ctx context.Context, searchText string) ([]model.PackageSourceOrArtifact, error)
}

// BackendArgs interface allows each backend to specify the arguments needed to
Expand Down
27 changes: 27 additions & 0 deletions pkg/assembler/backends/inmem/search.go
@@ -0,0 +1,27 @@
//
// Copyright 2023 The GUAC Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package inmem

import (
"context"
"fmt"

"github.com/guacsec/guac/pkg/assembler/graphql/model"
)

func (c *demoClient) FindSoftware(ctx context.Context, searchText string) ([]model.PackageSourceOrArtifact, error) {
return []model.PackageSourceOrArtifact{}, fmt.Errorf("not implemented: FindSoftware")
}
27 changes: 27 additions & 0 deletions pkg/assembler/backends/neo4j/search.go
@@ -0,0 +1,27 @@
//
// Copyright 2023 The GUAC Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package neo4j

import (
"context"
"fmt"

"github.com/guacsec/guac/pkg/assembler/graphql/model"
)

func (c *neo4jClient) FindSoftware(ctx context.Context, searchText string) ([]model.PackageSourceOrArtifact, error) {
return []model.PackageSourceOrArtifact{}, fmt.Errorf("not implemented: FindSoftware")
}

0 comments on commit d29cbb8

Please sign in to comment.