-
Notifications
You must be signed in to change notification settings - Fork 282
feat: Schema Service: Environment Functionality - BED-6852 #2220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
29da793
a7f351e
bc97cb0
bce213b
479fb18
89998ee
6ded4e3
6c08285
4ae5dfb
a3d9422
5987407
e76b52d
75b6804
38186be
ab74bf1
d63427f
bad51d2
6e4ba47
f94cb7c
3c5f688
85b9407
be02063
094d52a
be0c964
86560a5
434fb40
1cab880
b9cbb50
471fc4e
1de71fc
a2427b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // Copyright 2026 Specter Ops, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 | ||
| // 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. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| package v2 | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "fmt" | ||
| "net/http" | ||
|
|
||
| "github.com/specterops/bloodhound/cmd/api/src/api" | ||
| ) | ||
|
|
||
| //go:generate go run go.uber.org/mock/mockgen -copyright_file ../../../../../LICENSE.header -destination=./mocks/graphschemaextensions.go -package=mocks . OpenGraphSchemaService | ||
| type OpenGraphSchemaService interface { | ||
| UpsertGraphSchemaExtension(ctx context.Context, req GraphSchemaExtension) error | ||
| } | ||
|
|
||
| type GraphSchemaExtension struct { | ||
| Environments []Environment `json:"environments"` | ||
| } | ||
|
|
||
| type Environment struct { | ||
| EnvironmentKind string `json:"environmentKind"` | ||
| SourceKind string `json:"sourceKind"` | ||
| PrincipalKinds []string `json:"principalKinds"` | ||
| } | ||
|
|
||
| // TODO: Implement this - skeleton endpoint to simply test the handler. | ||
| func (s Resources) OpenGraphSchemaIngest(response http.ResponseWriter, request *http.Request) { | ||
| var ( | ||
| ctx = request.Context() | ||
| ) | ||
|
|
||
| var req GraphSchemaExtension | ||
| if err := json.NewDecoder(request.Body).Decode(&req); err != nil { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you know if we plan to use JSONSchema in the API handler, similar to what is done for OpenGraph ingest? curious if lawson is using it for his work. we may want to reject bad requests with 400 at the API layer but that may be coming in a follow up? just leaving this as a note here so i dont forget but lemme know
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like Lawson is doing something similar.. I was kind of basing my work off of this example in the RFC. Side note (and probably a question for my other PR) but do you know if findings and remediations get uploaded in the same way? I guess I'm not sure what the use case is for this handler. |
||
| api.WriteErrorResponse(request.Context(), api.BuildErrorResponse(http.StatusBadRequest, api.ErrorResponsePayloadUnmarshalError, request), response) | ||
| return | ||
| } | ||
|
|
||
| if err := s.openGraphSchemaService.UpsertGraphSchemaExtension(ctx, req); err != nil { | ||
| api.WriteErrorResponse(request.Context(), api.BuildErrorResponse(http.StatusInternalServerError, fmt.Sprintf("error upserting graph schema extension: %v", err), request), response) | ||
| return | ||
| } | ||
|
|
||
| response.WriteHeader(http.StatusCreated) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.