diff --git a/.github/workflows/pytest-linux.yml b/.github/workflows/pytest-linux.yml index 76ff0f8a9..2b0af03cc 100644 --- a/.github/workflows/pytest-linux.yml +++ b/.github/workflows/pytest-linux.yml @@ -28,6 +28,7 @@ jobs: - uses: actions/checkout@v4.1.1 with: submodules: true + token: ${{ secrets.OXOTITAN_GITHUB_KEY }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5.0.0 with: diff --git a/.github/workflows/pytest-windows.yml b/.github/workflows/pytest-windows.yml index eacc25a34..605b2d2c7 100644 --- a/.github/workflows/pytest-windows.yml +++ b/.github/workflows/pytest-windows.yml @@ -28,6 +28,7 @@ jobs: - uses: actions/checkout@v4.1.1 with: submodules: true + token: ${{ secrets.OXOTITAN_GITHUB_KEY }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5.0.0 with: diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 135b74422..41da1354d 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -11,16 +11,26 @@ name: Upload Python Package on: release: types: [published] - jobs: deploy: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4.1.1 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/setup-python@v5.0.0 with: @@ -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/checkout@v4.1.1 - - - 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 diff --git a/.github/workflows/release_linux_mac_bin.yaml b/.github/workflows/release_linux_mac_bin.yaml index d2d4c3a7d..436e624b2 100644 --- a/.github/workflows/release_linux_mac_bin.yaml +++ b/.github/workflows/release_linux_mac_bin.yaml @@ -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: @@ -34,4 +47,4 @@ jobs: - name: Release uses: softprops/action-gh-release@v2 with: - files: dist/oxo_${{ matrix.os }} \ No newline at end of file + files: dist/oxo_${{ matrix.os }} diff --git a/.github/workflows/release_windows_bin.yaml b/.github/workflows/release_windows_bin.yaml index 9f312a36a..d8a9fc05f 100644 --- a/.github/workflows/release_windows_bin.yaml +++ b/.github/workflows/release_windows_bin.yaml @@ -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: @@ -34,4 +47,4 @@ jobs: - name: Release uses: softprops/action-gh-release@v2 with: - files: dist/oxo_${{ matrix.os }}.exe \ No newline at end of file + files: dist/oxo_${{ matrix.os }}.exe diff --git a/.gitmodules b/.gitmodules index a16052f22..d27a7d7e9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/src/ostorlab/serve_app/app.py b/src/ostorlab/serve_app/app.py index a7a6bdca4..7b6f823a8 100644 --- a/src/ostorlab/serve_app/app.py +++ b/src/ostorlab/serve_app/app.py @@ -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: diff --git a/src/ostorlab/serve_app/oxo.py b/src/ostorlab/serve_app/oxo.py index 1e48c22ed..dc951a782 100644 --- a/src/ostorlab/serve_app/oxo.py +++ b/src/ostorlab/serve_app/oxo.py @@ -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), @@ -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: @@ -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) @@ -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): diff --git a/src/ostorlab/serve_app/types.py b/src/ostorlab/serve_app/types.py index 8cd5f5d83..7e999d9e7 100644 --- a/src/ostorlab/serve_app/types.py +++ b/src/ostorlab/serve_app/types.py @@ -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) diff --git a/src/oxotitan b/src/oxotitan new file mode 160000 index 000000000..9e12c3f44 --- /dev/null +++ b/src/oxotitan @@ -0,0 +1 @@ +Subproject commit 9e12c3f448caeae3d71fb136a3995baccda75090 diff --git a/tests/serve_app/oxo_test.py b/tests/serve_app/oxo_test.py index 91627c83e..a3e2ff719 100644 --- a/tests/serve_app/oxo_test.py +++ b/tests/serve_app/oxo_test.py @@ -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.""" @@ -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"]