Skip to content
Merged
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
47 changes: 47 additions & 0 deletions front/src/ctfnote/parsers/hitcon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ParsedTask, Parser } from '.';
import { parseJsonStrict } from '../utils';

const HitconParser: Parser = {
name: 'HITCONCTF parser',
hint: 'paste hitcon /dashboard/challenge_data',
parse(s): ParsedTask[] {
const tasks: ParsedTask[] = [];
const data =
parseJsonStrict<
[{ name: string; category: string; description: string }]
>(s);
if (data == null) {
return [];
}

for (const challenge of data) {
if (!challenge.description || !challenge.name) {
continue;
}

tasks.push({
title: challenge.name,
tags: challenge.category.split(','),
description: challenge.description,
});
}

return tasks;
},
isValid(s) {
const data =
parseJsonStrict<
[{ name: string; category: string; description: string }]
>(s);
if (data == null || data.length < 1) {
return false;
}
return (
data[0].name != null &&
data[0].category != null &&
data[0].description != null
);
},
};

export default HitconParser;
2 changes: 2 additions & 0 deletions front/src/ctfnote/parsers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import HTBParser from './htb';
import PicoParser from './pico';
import justCTFParser from './justctf';
import AngstromParser from './angstrom';
import HitconParser from './hitcon';

export type ParsedTask = {
title: string;
Expand All @@ -28,4 +29,5 @@ export default [
PicoParser,
justCTFParser,
AngstromParser,
HitconParser,
];