Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/crunch42-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "42Crunch REST API Static Security Testing"

# follow standard Code Scanning triggers
on:
push:
branches: [ main ]
pull_request_target:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '19 4 * * 3'

jobs:
rest-api-static-security-testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install DOMjudge
run: .github/workflowscripts/baseinstall.sh

- name: Dump the OpenAPI
run: .github/workflowscripts/getapi.sh

- name: Find all other JSON files and delete those
run: |
rm -rf ./installdir/domserver/lib/vendor ./lib/vendor
rm -f ./doc/manual/sphinx-team.json ./doc/manual/sphinx-team.json
find ./ -name "*.json"

- name: 42Crunch REST API Static Security Testing
uses: 42Crunch/api-security-audit-action@v1
with:
# Follow these steps to configure API_SECRET https://docs.42crunch.com/latest/content/tasks/integrate_github_actions.htm
api-token: ${{ secrets.API_SECRET }}
min-score: 9
# Upload results to Github code scanning
upload-to-code-scanning: true
# Github token for uploading the results
github-token: ${{ github.token }}
ignore-failures: false

4 changes: 4 additions & 0 deletions .github/workflows/mayhem-api.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: "Mayhem API analysis"

on:
push:
branches: [ main ]
pull_request_target:
branches: [ main ]
schedule:
- cron: '5 21 * * *'

Expand Down
7 changes: 5 additions & 2 deletions lib/lib.error.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
#include <ctype.h>

/* Define va_copy macro if not available (ANSI C99 only).
* memcpy() is fallback suggested by the autoconf manual, but doesn't
Expand Down Expand Up @@ -63,8 +65,9 @@ char *printf_escape(const char *str)

for(str_pos=0; str_pos<strlen(str); str_pos++) {
c = str[str_pos];
escaped[esc_pos++] = c;
if ( c=='%' ) escaped[esc_pos++] = c;
if(isalnum(c)){
escaped[esc_pos++] = c;
}
}
escaped[esc_pos] = 0;

Expand Down
16 changes: 13 additions & 3 deletions webapp/config/packages/nelmio_api_doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ nelmio_api_doc:
components:
securitySchemes:
basicAuth:
type: http
type: https
scheme: basic
parameters:
cid:
Expand All @@ -19,6 +19,8 @@ nelmio_api_doc:
required: true
schema:
type: string
pattern: "^[A-Za-z0-9]{1,255}$"
maxLength: 255
examples:
int0:
value: "2"
Expand All @@ -36,6 +38,8 @@ nelmio_api_doc:
required: true
schema:
type: integer
minimum: 1
maximum: 9999
examples:
balloon:
value: 1
Expand All @@ -46,7 +50,10 @@ nelmio_api_doc:
description: The ID of the entity to get
required: true
schema:
$ref: "#/components/schemas/Id"
type: string
pattern: "^[A-Za-z0-9]{1,255}$"
maxLength: 255
examples:
generic:
value: "1"
Expand All @@ -68,8 +75,7 @@ nelmio_api_doc:
schema:
type: array
items:
type: string
description: A single ID
$ref: "#/components/schemas/Id"
strict:
name: strict
in: query
Expand Down Expand Up @@ -97,6 +103,10 @@ nelmio_api_doc:
schema:
type: string
schemas:
Id:
type: string
pattern: "^[A-Za-z0-9]{1,255}$"
maxLength: 255
ImageList:
type: array
items:
Expand Down
1 change: 1 addition & 0 deletions webapp/src/Controller/API/AbstractRestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

/**
* Class AbstractRestController
* @OA\Response(response="400", ref="#/components/responses/InvalidResponse")
* @package App\Controller\API
*/
abstract class AbstractRestController extends AbstractFOSRestController
Expand Down
4 changes: 0 additions & 4 deletions webapp/src/Controller/API/ContestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,6 @@ public function setBannerAction(Request $request, string $id, ValidatorInterface
* description="Contest start time changed successfully",
* )
* @OA\Response(
* response="400",
* description="Invalid input data"
* )
* @OA\Response(
* response="403",
* description="Changing start time not allowed"
* )
Expand Down
1 change: 1 addition & 0 deletions webapp/src/Controller/API/GeneralInfoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

/**
* @OA\Tag(name="General")
* @OA\Response(response="400", ref="#/components/responses/InvalidResponse")
*/
class GeneralInfoController extends AbstractFOSRestController
{
Expand Down
38 changes: 38 additions & 0 deletions webapp/src/Controller/API/JudgehostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,44 @@ private function getTestcaseFiles(string $id): array
/**
* Fetch work tasks.
* @Rest\Post("/fetch-work")
* @OA\RequestBody(
* description="The hostname of the judgedaemon requesting.",
* @OA\JsonContent(
* required={"hostname"},
* @OA\Property(
* property="hostname",
* type="string",
* format="string",
* description="Hostname of judgedaemon"
* ),
* @OA\Property(
* property="max-batchsize",
* type="integer",
* format="integer",
* description="Maximum size judge requests to handle"
* ),
* @OA\Schema(
* @OA\Property(
* property="hostname",
* type="string",
* format="string",
* description="Hostname of judgedaemon"
* ),
* @OA\Property(
* property="max-batchsize",
* type="integer",
* format="integer",
* description="Maximum size judge requests to handle"
* ),
* ),
* @OA\Examples(example="example-data", value={"hostname": "example-judgehost1"}, summary="Fetch work with example judgedaemon."),
* )
* )
* @OA\Response(
* response="200",
* description="List of judgeTasks.",
* @OA\Schema(ref="#/definitions/JudgeTaskList")
* )
* @Security("is_granted('ROLE_JUDGEHOST')")
*/
public function getJudgeTasksAction(Request $request): array
Expand Down
Binary file not shown.