Skip to content

Commit

Permalink
config valmis
Browse files Browse the repository at this point in the history
  • Loading branch information
PootisHunter committed Jul 10, 2024
2 parents d881ef6 + e05ba41 commit a489e48
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 28 deletions.
22 changes: 11 additions & 11 deletions course.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Course Configuration

# UUIDv7
identifier = "01908498-ac98-708d-b886-b6f2747ef785"
name = "Cybersecurity"
identifier = "01908498-ac98-708d-b886-b6f2747ef785" #pakollinen
name = "Cybersecurity" # pakollinen
description = "A comprehensive course covering various aspects of cybersecurity"
# We likely need to think this further. If some task is changed, this should be changed as well.
version = "0.0.1"
version = "0.0.1" #pakollinen

# Weeks Configuration
[[weeks]]
number = 1
theme = "Introduction to Cybersecurity"
number = 1 #pakollinen
theme = "Introduction to Cybersecurity"

[[weeks.tasks]]
# Tasks can be a single whole task or tasks with sub-parts (a, b c)
# As long as identifier is unique on course level, we need to use something which reminds us about the actual task relation
# Overall ID is used as flag prefix. Maybe further obfuscation needed for that but maybe not necessary
# If the task includes subtasks, embed subtask IDs as suffix
id = "task001"
name = "Challenge 1"
description = "Exploit few buffer overflow vulnerabilities"
id = "task001" #pakollinen
name = "Challenge 1" #pakollinen
description = "Exploit few buffer overflow vulnerabilities"
# Note the float type here
points = 1.0
points = 1.0 #pakollinen
# Same build can embed many flags at once
# As a result, it is more clear to introduce list here instead of repeating multiple tasks without build
# `id` is used to make order explicit and tie flag into task
Expand All @@ -46,7 +46,7 @@ subtasks = [

[weeks.tasks.build]
directory = "tasks/week1/buffer_overflow"
entrypoint = "build.sh"
entrypoint = "build.sh" #default
builder = "shell"

[[weeks.tasks.build.output]]
Expand Down Expand Up @@ -155,7 +155,7 @@ type = "readme"
# Flag Types Configuration
# TOML reader must raise an error if selected one is not one of these
[flag_types]
pure_random = { length = 32 }
pure_random = { length = 32 } # default 32
# Secret is required so that the flag can be deterministic based on the user, but it should not be possible to guess
# Secret in here should be identifier for secret in vault software, instead of storing it directly here...
# Key must be 32 bytes at least, NOTE that in concatenation!
Expand Down
71 changes: 54 additions & 17 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,31 @@ use uuid::{uuid, Uuid};

use crate::flag_generator::Flag;

#[derive(Deserialize)]
#[derive(Deserialize,Clone)]

pub struct CourseConfiguration {
pub course_identifier: CourseIdentifier,
pub weeks: Vec<Weeks>,
<<<<<<< HEAD
pub taskbuild: Vec<WeeksTasksBuild>,
=======
pub tasks: Vec<WeeksTasks>,
pub taskbuild: WeeksTasksBuild,
>>>>>>> e05ba41fc8ced75fcdf6946c1e93b172b71ff364
pub taskoutput: Vec<WeeksTasksOutput>,
}

impl CourseConfiguration {
<<<<<<< HEAD
pub fn new(
course_identifier: CourseIdentifier,
weeks: Vec<Weeks>,
taskbuild: Vec<WeeksTasksBuild>,
taskoutput: Vec<WeeksTasksOutput>,
) -> CourseConfiguration {
=======
pub fn new(course_identifier: CourseIdentifier, weeks: Vec<Weeks>, tasks: Vec<WeeksTasks>, taskbuild: WeeksTasksBuild, taskoutput: Vec<WeeksTasksOutput>) -> CourseConfiguration {
>>>>>>> e05ba41fc8ced75fcdf6946c1e93b172b71ff364
CourseConfiguration {
course_identifier,
weeks,
Expand All @@ -30,22 +40,21 @@ impl CourseConfiguration {
}
}

#[derive(Deserialize)]
#[derive(Deserialize,Clone)]
pub struct CourseIdentifier {
<<<<<<< HEAD
//TODO:Change to UUID
=======
//Change to UUID
>>>>>>> e05ba41fc8ced75fcdf6946c1e93b172b71ff364
pub identifier: String,
pub name: String,
pub description: String,
pub version: String,
}

impl CourseIdentifier {
pub fn new(
identifier: String,
name: String,
description: String,
version: String,
) -> CourseIdentifier {
pub fn new(identifier: String, name: String, description: String, version: String) -> CourseIdentifier {
CourseIdentifier {
identifier,
name,
Expand All @@ -54,28 +63,37 @@ impl CourseIdentifier {
}
}
}
#[derive(Deserialize)]
#[derive(Deserialize,Clone)]
pub struct Weeks {
<<<<<<< HEAD
pub tasks: Vec<WeeksTasks>,
=======
>>>>>>> e05ba41fc8ced75fcdf6946c1e93b172b71ff364
pub number: i32,
pub theme: String,
}

impl Weeks {
<<<<<<< HEAD
pub fn new(tasks: Vec<WeeksTasks>, number: i32, theme: String) -> Weeks {
Weeks {
tasks,
=======
pub fn new(number: i32, theme: String) -> Weeks {
Weeks {
>>>>>>> e05ba41fc8ced75fcdf6946c1e93b172b71ff364
number,
theme,
}
}
}
#[derive(Deserialize)]
#[derive(Deserialize,Clone)]
pub struct WeeksTasks {
pub id: String,
pub name: String,
pub description: String,
pub points: f32,
<<<<<<< HEAD
pub flags: Vec<FlagConfig>,
pub subtasks: Option<Vec<SubTask>>,
}
Expand All @@ -89,6 +107,14 @@ impl WeeksTasks {
flags: Vec<FlagConfig>,
subtasks: Option<Vec<SubTask>>,
) -> WeeksTasks {
=======
pub flags: Vec<Flag>,
pub subtasks: Vec<SubTask>,
}

impl WeeksTasks {
pub fn new(id: String, name: String, description: String, points: f32, flags: Vec<Flag>, subtasks: Vec<SubTask>) -> WeeksTasks {
>>>>>>> e05ba41fc8ced75fcdf6946c1e93b172b71ff364
WeeksTasks {
id,
name,
Expand All @@ -99,19 +125,27 @@ impl WeeksTasks {
}
}
}
<<<<<<< HEAD
#[derive(Deserialize)]
pub struct FlagConfig {
=======
#[derive(Deserialize,Clone)]
pub struct Flag {
>>>>>>> e05ba41fc8ced75fcdf6946c1e93b172b71ff364
pub flag_type: String,
pub id: String,
}

impl FlagConfig {
pub fn new(flag_type: String, id: String) -> FlagConfig {
FlagConfig { flag_type, id }
impl Flag {
pub fn new(flag_type: String, id: String) -> Flag {
Flag {
flag_type,
id,
}
}
}

#[derive(Deserialize)]
#[derive(Deserialize,Clone)]
pub struct SubTask {
pub id: String,
pub name: String,
Expand All @@ -129,7 +163,7 @@ impl SubTask {
}
}
}
#[derive(Deserialize)]
#[derive(Deserialize,Clone)]
pub struct WeeksTasksBuild {
pub directory: String,
pub entrypoint: String,
Expand All @@ -145,15 +179,18 @@ impl WeeksTasksBuild {
}
}
}
#[derive(Deserialize)]
#[derive(Deserialize,Clone)]
pub struct WeeksTasksOutput {
pub name: String,
pub output_type: String,
}

impl WeeksTasksOutput {
pub fn new(name: String, output_type: String) -> WeeksTasksOutput {
WeeksTasksOutput { name, output_type }
WeeksTasksOutput {
name,
output_type,
}
}
}

Expand Down

0 comments on commit a489e48

Please sign in to comment.