Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-domain-name-model
Browse files Browse the repository at this point in the history
  • Loading branch information
elyousfi5 authored Jun 14, 2024
2 parents cce2e67 + b547e39 commit cb2aa1d
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 39 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pytest-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- uses: actions/[email protected]
with:
submodules: true
token: ${{ secrets.OXOTITAN_GITHUB_KEY }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pytest-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- uses: actions/[email protected]
with:
submodules: true
token: ${{ secrets.OXOTITAN_GITHUB_KEY }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
Expand Down
61 changes: 32 additions & 29 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,26 @@ name: Upload Python Package
on:
release:
types: [published]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]
with:
submodules: true
token: ${{ secrets.OXOTITAN_GITHUB_KEY }}
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18.0.0'
- name: Install Node dependencies
run: npm install
working-directory: src/oxotitan
- name: Generate Nuxt
run: npm run generate
working-directory: src/oxotitan
- name: Copy Nuxt output
run: cp -r src/oxotitan/.output/public src/ostorlab/ui/static
- name: Set up Python
uses: actions/[email protected]
with:
Expand All @@ -41,29 +51,22 @@ jobs:
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
push_to_store:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Login to ostorlab store
uses: docker/login-action@v1
with:
username: ${{ secrets.store_user }}
password: ${{ secrets.store_password }}
- name: truncate current tag
run: echo "TAG=$(echo $GITHUB_REF | cut -c12-17)" >> $GITHUB_ENV
- name: Build image and push to ostorlab Container Registry
uses: docker/build-push-action@v2
with:
# relative path to the place where source code with Dockerfile is located
context: .
tags: |
ostorlab/oxo:${{env.TAG}}
ostorlab/oxo:latest
push: true
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to ostorlab store
uses: docker/login-action@v1
with:
username: ${{ secrets.store_user }}
password: ${{ secrets.store_password }}
- name: truncate current tag
run: echo "TAG=$(echo $GITHUB_REF | cut -c12-17)" >> $GITHUB_ENV
- name: Build image and push to ostorlab Container Registry
uses: docker/build-push-action@v2
with:
# relative path to the place where source code with Dockerfile is located
context: .
tags: |
ostorlab/oxo:${{env.TAG}}
ostorlab/oxo:latest
push: true
15 changes: 14 additions & 1 deletion .github/workflows/release_linux_mac_bin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.OXOTITAN_GITHUB_KEY }}
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18.0.0'
- name: Install Node dependencies
run: npm install
working-directory: src/oxotitan
- name: Generate Nuxt
run: npm run generate
working-directory: src/oxotitan
- name: Copy Nuxt output
run: cp -r src/oxotitan/.output/public src/ostorlab/ui/static
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
Expand All @@ -34,4 +47,4 @@ jobs:
- name: Release
uses: softprops/action-gh-release@v2
with:
files: dist/oxo_${{ matrix.os }}
files: dist/oxo_${{ matrix.os }}
15 changes: 14 additions & 1 deletion .github/workflows/release_windows_bin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.OXOTITAN_GITHUB_KEY }}
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18.0.0'
- name: Install Node dependencies
run: npm install
working-directory: src/oxotitan
- name: Generate Nuxt
run: npm run generate
working-directory: src/oxotitan
- name: Copy Nuxt output
run: cp -r src/oxotitan/.output/public src/ostorlab/ui/static
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
Expand All @@ -34,4 +47,4 @@ jobs:
- name: Release
uses: softprops/action-gh-release@v2
with:
files: dist/oxo_${{ matrix.os }}.exe
files: dist/oxo_${{ matrix.os }}.exe
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
url = https://github.com/Ostorlab/KB.git
branch = master

[submodule "src/oxotitan"]
path = src/oxotitan
url = https://github.com/ostorlab/oxotitan.git
branch = main
2 changes: 1 addition & 1 deletion src/ostorlab/serve_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

AUTHORIZATION_HEADER = "X-API-KEY"

UI_STATIC_FILES_DIRECTORY = pathlib.Path(__file__).parent.parent / "ui/static_files"
UI_STATIC_FILES_DIRECTORY = pathlib.Path(__file__).parent.parent / "ui/static"


def create_app(path: str = "/graphql", **kwargs) -> flask.Flask:
Expand Down
10 changes: 5 additions & 5 deletions src/ostorlab/serve_app/oxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Query(graphene.ObjectType):
)

agent_groups = graphene.Field(
types.AgentGroupsType,
types.OxoAgentGroupsType,
search=graphene.String(required=False),
page=graphene.Int(required=False),
number_elements=graphene.Int(required=False),
Expand Down Expand Up @@ -156,7 +156,7 @@ def resolve_agent_groups(
sort: Optional[common.SortEnum] = None,
agent_group_ids: Optional[List[int]] = None,
asset_type: Optional[str] = None,
) -> types.AgentGroupsType:
) -> types.OxoAgentGroupsType:
"""Resolve agent groups query.
Args:
Expand All @@ -173,7 +173,7 @@ def resolve_agent_groups(
"""

if number_elements <= 0:
return types.AgentGroupsType(agent_groups=[])
return types.OxoAgentGroupsType(agent_groups=[])

with models.Database() as session:
agent_groups_query = session.query(models.AgentGroup)
Expand Down Expand Up @@ -221,9 +221,9 @@ def resolve_agent_groups(
has_next=page.has_next(),
has_previous=page.has_previous(),
)
return types.AgentGroupsType(agent_groups=page, page_info=page_info)
return types.OxoAgentGroupsType(agent_groups=page, page_info=page_info)
else:
return types.AgentGroupsType(agent_groups=agent_groups_query)
return types.OxoAgentGroupsType(agent_groups=agent_groups_query)


class ImportScanMutation(graphene.Mutation):
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/serve_app/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ def resolve_asset_types(
return [asset.type for asset in asset_types]


class AgentGroupsType(graphene.ObjectType):
class OxoAgentGroupsType(graphene.ObjectType):
agent_groups = graphene.List(AgentGroupType, required=True)
page_info = graphene.Field(common.PageInfo, required=False)

Expand Down
1 change: 1 addition & 0 deletions src/oxotitan
Submodule oxotitan added at 9e12c3
5 changes: 4 additions & 1 deletion tests/serve_app/oxo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2909,7 +2909,6 @@ def testOxoSchemaReOxoSchemas_whenInputObject_schemasShouldBeSimilar() -> None:
assert input_field_type == oxo_input_types[input_field_name]


@pytest.mark.skip(reason="Schema not complete on RE_OXO.")
def testOxoSchemaReOxoSchemas_whenMutations_schemasShouldBeSimilar() -> None:
"""Ensure the `Mutations` in the OxO Schema & RE_OxO schema are similar."""

Expand Down Expand Up @@ -2940,6 +2939,10 @@ def testOxoSchemaReOxoSchemas_whenMutations_schemasShouldBeSimilar() -> None:
oxo_mutations = {mutation["name"]: mutation for mutation in oxo_mutations_fields}

for mutation_name, mutation_fields in re_oxo_mutations.items():
if mutation_name == "exportScan":
# This mutation is explicitly skipped from the check.
# TODO(deadly-panda): Evaluate if exporting scans on oxo is a valid usecase.
continue
assert mutation_name in oxo_mutations

assert mutation_fields["type"] == oxo_mutations[mutation_name]["type"]
Expand Down

0 comments on commit cb2aa1d

Please sign in to comment.