-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1afc7f
commit 201e655
Showing
15 changed files
with
461 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
akic | ||
baf | ||
bru | ||
cgrp | ||
chronos | ||
Ckxomxaar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Mondoo GraphQL API Samples | ||
|
||
This repository contains sample queries for the Mondoo GraphQL API. The queries are written in GraphQL and can be executed using the [Bruno](https://docs.usebruno.com/). | ||
|
||
## Getting Started | ||
|
||
- Clone this repository | ||
- Install Bruno | ||
- Setup .env file with your Mondoo API key | ||
|
||
|
||
## API Key | ||
|
||
To get started with the Mondoo API, you need to create an API key. You can create an API key in the Mondoo console. Then create a `.env` file in the root of the repository with the following content: | ||
|
||
``` | ||
MONDOO_API_TOKEN=your-api-key | ||
MONDOO_ENDPOINT=us.api.mondoo.com | ||
SPACE_MRN=//captain.api.mondoo.app/spaces/mystifying-jennings-299629 | ||
ORG_MRN=//captain.api.mondoo.app/organizations/lunalectric | ||
``` | ||
|
||
> NOTE: While not technically required, it is recommended to use a organization API token with editor permissions to sure all samples work. | ||
## CLI | ||
|
||
Follow the installation instructions[https://docs.usebruno.com/bru-cli/overview]. | ||
|
||
``` | ||
bru run search/search.bru --env Mondoo | ||
``` | ||
|
||
## APP | ||
|
||
Follow the installation instructions[https://www.usebruno.com/downloads]. Then you open the collection and run the queries. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
meta { | ||
name: list_assets_in_space | ||
type: graphql | ||
seq: 1 | ||
} | ||
|
||
post { | ||
url: https://{{endpoint}}/query | ||
body: graphql | ||
auth: bearer | ||
} | ||
|
||
auth:bearer { | ||
token: {{MONDOO_API_TOKEN}} | ||
} | ||
|
||
body:graphql { | ||
query Assets { | ||
assets(spaceMrn: "{{spaceMrn}}") { | ||
totalCount | ||
edges { | ||
cursor | ||
node { | ||
id | ||
mrn | ||
state | ||
name | ||
updatedAt | ||
referenceIDs | ||
asset_type | ||
score { | ||
grade | ||
value | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"version": "1", | ||
"name": "Mondoo GraphQL API Requests", | ||
"type": "collection", | ||
"ignore": [ | ||
"node_modules", | ||
".git" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
vars { | ||
endpoint: {{process.env.MONDOO_ENDPOINT}} | ||
spaceMrn: {{process.env.SPACE_MRN}} | ||
orgMrn: {{process.env.ORG_MRN}} | ||
MONDOO_API_TOKEN: {{process.env.MONDOO_API_TOKEN}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
meta { | ||
name: list_members | ||
type: graphql | ||
seq: 2 | ||
} | ||
|
||
post { | ||
url: https://{{endpoint}}/query | ||
body: graphql | ||
auth: bearer | ||
} | ||
|
||
auth:bearer { | ||
token: {{MONDOO_API_TOKEN}} | ||
} | ||
|
||
body:graphql { | ||
query LoadOrganizationMembers { | ||
organization(mrn: "{{orgMrn}}") { | ||
id | ||
mrn | ||
members { | ||
edges { | ||
node { | ||
user { | ||
name | ||
} | ||
roles { | ||
title | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
meta { | ||
name: list_service_accounts | ||
type: graphql | ||
seq: 3 | ||
} | ||
|
||
post { | ||
url: https://{{endpoint}}/query | ||
body: graphql | ||
auth: bearer | ||
} | ||
|
||
auth:bearer { | ||
token: {{MONDOO_API_TOKEN}} | ||
} | ||
|
||
body:graphql { | ||
# To list all service accounts, the API Token needs Editor permissions | ||
query ServiceAccounts( | ||
$scopeMrn: String | ||
$first: Int | ||
$after: String | ||
$query: String | ||
$queryTerms: [String!] | ||
$orderBy: ServiceAccountOrder | ||
) { | ||
serviceAccounts( | ||
scopeMrn: $scopeMrn | ||
first: $first | ||
after: $after | ||
query: $query | ||
queryTerms: $queryTerms | ||
orderBy: $orderBy | ||
) { | ||
...ServiceAccountFields | ||
__typename | ||
} | ||
} | ||
fragment ServiceAccountFields on ServiceAccountConnection { | ||
totalCount | ||
edges { | ||
cursor | ||
node { | ||
id | ||
mrn | ||
name | ||
description | ||
roles { | ||
mrn | ||
title | ||
__typename | ||
} | ||
createdAt | ||
lastUsed | ||
labels { | ||
key | ||
value | ||
__typename | ||
} | ||
creator { | ||
mrn | ||
service | ||
__typename | ||
} | ||
notes | ||
__typename | ||
} | ||
__typename | ||
} | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasNextPage | ||
__typename | ||
} | ||
__typename | ||
} | ||
|
||
} | ||
|
||
body:graphql:vars { | ||
{ | ||
"scopeMrn": "{{spaceMrn}}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
meta { | ||
name: list_spaces | ||
type: graphql | ||
seq: 1 | ||
} | ||
|
||
post { | ||
url: https://{{endpoint}}/query | ||
body: graphql | ||
auth: bearer | ||
} | ||
|
||
auth:bearer { | ||
token: {{MONDOO_API_TOKEN}} | ||
} | ||
|
||
body:graphql { | ||
query OrganizationOverview { | ||
organizationOverview( | ||
input: { organizationMrn: "{{orgMrn}}" } | ||
) { | ||
organizationMrn | ||
spacesOverview { | ||
spaceMrn | ||
spaceName | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
meta { | ||
name: enable_policy | ||
type: graphql | ||
seq: 2 | ||
} | ||
|
||
post { | ||
url: https://{{endpoint}}/query | ||
body: graphql | ||
auth: bearer | ||
} | ||
|
||
auth:bearer { | ||
token: {{MONDOO_API_TOKEN}} | ||
} | ||
|
||
body:graphql { | ||
mutation { | ||
assignPolicy( | ||
input: { | ||
assetMrn: "{{spaceMrn}}" | ||
policyMrn: "//policy.api.mondoo.app/policies/mondoo-dns-security" | ||
action: ACTIVE | ||
} | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
meta { | ||
name: list_active_policies | ||
type: graphql | ||
seq: 4 | ||
} | ||
|
||
post { | ||
url: https://{{endpoint}}/query | ||
body: graphql | ||
auth: bearer | ||
} | ||
|
||
auth:bearer { | ||
token: {{MONDOO_API_TOKEN}} | ||
} | ||
|
||
body:graphql { | ||
query SpaceReport($input: SpaceReportInput!) { | ||
spaceReport(input: $input) { | ||
... on SpaceReport { | ||
spaceMrn | ||
policyReportSummaries { | ||
totalCount | ||
edges { | ||
cursor | ||
node { | ||
policy { | ||
mrn | ||
name | ||
assigned | ||
action | ||
version | ||
isPublic | ||
createdAt | ||
updatedAt | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
body:graphql:vars { | ||
{ | ||
"input" : { | ||
"spaceMrn" : "{{spaceMrn}}" | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
graphql-api/policies_querypacks/list_available_policies_query_packs.bru
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
meta { | ||
name: list_available_policies_query_packs | ||
type: graphql | ||
seq: 3 | ||
} | ||
|
||
post { | ||
url: https://{{endpoint}}/query | ||
body: graphql | ||
auth: bearer | ||
} | ||
|
||
auth:bearer { | ||
token: {{MONDOO_API_TOKEN}} | ||
} | ||
|
||
body:graphql { | ||
{ | ||
content( | ||
input: { scopeMrn: "{{spaceMrn}}", catalogType: ALL, assignedOnly: true } | ||
) { | ||
totalCount | ||
edges { | ||
node { | ||
__typename | ||
... on Policy { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.