diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index f359c47d6..5f6e55dd4 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -26,14 +26,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - uses: greenbone/actions/is-latest-tag@v3 id: latest - name: Setup container meta information id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ${{ github.repository }}-build labels: | @@ -65,17 +65,17 @@ jobs: fi - name: Login to DockerHub if: github.event_name != 'pull_request' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - run: echo "Build and push ${{ steps.meta.outputs.tags }}" - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . push: ${{ github.event_name != 'pull_request' }} diff --git a/.github/workflows/ci-c.yml b/.github/workflows/ci-c.yml index de0537600..58ee17c82 100644 --- a/.github/workflows/ci-c.yml +++ b/.github/workflows/ci-c.yml @@ -11,7 +11,7 @@ jobs: name: Check C Source Code Formatting runs-on: "ubuntu-latest" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Check Source Format run: | clang-format -i -style=file src/*.{c,h} @@ -25,7 +25,7 @@ jobs: - greenbone/gsad-build:stable container: ${{ matrix.container }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Configure and compile gsad run: | mkdir build @@ -39,7 +39,7 @@ jobs: runs-on: ubuntu-latest container: greenbone/gsad-build:stable steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Configure and compile gsad run: | cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=1 . diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 03ebe1dff..e4173d139 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 49141f1c9..1b8d4b4f2 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -16,14 +16,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - uses: greenbone/actions/is-latest-tag@v3 id: latest - name: Setup container meta information id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ${{ github.repository }} labels: | @@ -57,16 +57,16 @@ jobs: fi - name: Login to Docker Registry if: github.event_name != 'pull_request' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build and push Container image - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . push: ${{ github.event_name != 'pull_request' && (github.ref_type == 'tag' || github.ref_name == 'main') }} diff --git a/src/gsad_http_handler.c b/src/gsad_http_handler.c index 98f49ea32..2c50ac867 100644 --- a/src/gsad_http_handler.c +++ b/src/gsad_http_handler.c @@ -753,26 +753,19 @@ handle_static_config (http_connection_t *connection, const char *method, NULL); } -http_handler_t * -init_http_handlers () +static http_handler_t * +make_url_handlers () { - http_handler_t *method_router; - http_handler_t *gmp_post_handler; http_handler_t *url_handlers; - - http_validator = gvm_validator_new (); - gvm_validator_add (http_validator, "slave_id", SLAVE_ID_REGEXP); - gvm_validator_add (http_validator, "token", TOKEN_REGEXP); - - handlers = http_handler_new (handle_validate); - - method_router = method_router_new (); - gmp_post_handler = http_handler_new (handle_gmp_post); - - http_handler_add (handlers, method_router); + http_handler_t *gmp_handler, *gmp_url_handler; + http_handler_t *system_report_handler, *system_report_url_handler; + http_handler_t *logout_handler, *logout_url_handler; url_handlers = url_handler_new ("^/(img|js|css|locales)/.+$", http_handler_new (handle_static_file)); + + // Add simpler handlers. + url_handler_add_func (url_handlers, "^/robots\\.txt$", handle_static_file); url_handler_add_func (url_handlers, "^/config\\.*js$", handle_static_config); @@ -780,23 +773,30 @@ init_http_handlers () handle_static_file); url_handler_add_func (url_handlers, "^/manual/.+$", handle_static_file); - http_handler_t *gmp_handler = http_handler_new (handle_setup_user); + // Create /gmp handler. + + gmp_handler = http_handler_new (handle_setup_user); http_handler_add (gmp_handler, http_handler_new (handle_setup_credentials)); http_handler_add (gmp_handler, http_handler_new (handle_gmp_get)); - http_handler_t *gmp_url_handler = url_handler_new ("^/gmp$", gmp_handler); + gmp_url_handler = url_handler_new ("^/gmp$", gmp_handler); + + // Create /system_report handler. - http_handler_t *system_report_handler = http_handler_new (handle_setup_user); + system_report_handler = http_handler_new (handle_setup_user); http_handler_add (system_report_handler, http_handler_new (handle_setup_credentials)); http_handler_add (system_report_handler, http_handler_new (handle_system_report)); - http_handler_t *system_report_url_handler = + system_report_url_handler = url_handler_new ("^/system_report/.+$", system_report_handler); - http_handler_t *logout_handler = http_handler_new (handle_get_user); + // Create /logout handler. + + logout_handler = http_handler_new (handle_get_user); http_handler_add (logout_handler, http_handler_new (handle_logout)); - http_handler_t *logout_url_handler = - url_handler_new ("^/logout/?$", logout_handler); + logout_url_handler = url_handler_new ("^/logout/?$", logout_handler); + + // Add the handlers. http_handler_add (url_handlers, gmp_url_handler); http_handler_add (url_handlers, system_report_url_handler); @@ -804,6 +804,27 @@ init_http_handlers () http_handler_add (url_handlers, http_handler_new (handle_index)); + return url_handlers; +} + +http_handler_t * +init_http_handlers () +{ + http_handler_t *method_router, *gmp_post_handler, *url_handlers; + + http_validator = gvm_validator_new (); + gvm_validator_add (http_validator, "slave_id", SLAVE_ID_REGEXP); + gvm_validator_add (http_validator, "token", TOKEN_REGEXP); + + handlers = http_handler_new (handle_validate); + + method_router = method_router_new (); + gmp_post_handler = http_handler_new (handle_gmp_post); + + http_handler_add (handlers, method_router); + + url_handlers = make_url_handlers (); + method_router_set_get_handler (method_router, url_handlers); method_router_set_post_handler (method_router, gmp_post_handler);