-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from erdnaxe/ecsc-importer
CINI (ECSC 2024) importer
- Loading branch information
Showing
3 changed files
with
58 additions
and
31 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { ParsedTask, Parser } from '.'; | ||
import { parseJson, parseJsonStrict } from '../utils'; | ||
|
||
interface Events { | ||
gamePause?: unknown; | ||
events: [ | ||
{ | ||
id: number; | ||
name: string; | ||
sections: [ | ||
{ | ||
id: number; | ||
name: string; | ||
challenges: [ | ||
{ | ||
id: number; | ||
title: string; | ||
tags: string[]; | ||
authors: string[]; | ||
currentScore: number; | ||
currentGlobalSolves: number; | ||
hidden: boolean; | ||
} | ||
]; | ||
} | ||
]; | ||
} | ||
]; | ||
} | ||
|
||
const CINIParser: Parser = { | ||
name: 'Cybersecurity National Lab (CINI) platform and ECSC 2024 (Turin) parser', | ||
hint: 'paste platform /api/challenges', | ||
|
||
parse(s: string): ParsedTask[] { | ||
const tasks = []; | ||
const data = parseJsonStrict<Events>(s); | ||
|
||
for (const event of data.events) { | ||
for (const section of event.sections) { | ||
for (const chall of section.challenges) { | ||
tasks.push({ title: chall.title, tags: chall.tags }); | ||
} | ||
} | ||
} | ||
|
||
return tasks; | ||
}, | ||
isValid(s) { | ||
const data = parseJson<Events>(s); | ||
if (data == null) return false; | ||
return data.gamePause !== undefined && data.events !== undefined; | ||
}, | ||
}; | ||
|
||
export default CINIParser; |
This file was deleted.
Oops, something went wrong.
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