Skip to content

Commit

Permalink
Removed schema examples since schemar's support is lacking
Browse files Browse the repository at this point in the history
  • Loading branch information
gammelalf committed Apr 2, 2024
1 parent b7916a6 commit b71fcb2
Show file tree
Hide file tree
Showing 17 changed files with 5 additions and 122 deletions.
4 changes: 0 additions & 4 deletions kraken/src/api/handler/api_keys/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ use uuid::Uuid;
#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone)]
pub struct CreateApiKeyRequest {
/// A descriptive name helping the user to identify the key
// TODO #[schema(example = "Leech on my local machine")]
pub name: String,
}

/// The request to update an api key
#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone)]
pub struct UpdateApiKeyRequest {
/// A descriptive name helping the user to identify the key
// TODO #[schema(example = "Leech on my local machine")]
pub name: String,
}

Expand All @@ -26,11 +24,9 @@ pub struct FullApiKey {
pub uuid: Uuid,

/// A descriptive name helping the user to identify the key
// TODO #[schema(example = "Leech on my local machine")]
pub name: String,

/// The actual key's value
// TODO #[schema(example = "fsn83r0jfis84nfthw...")]
pub key: String,
}

Expand Down
4 changes: 2 additions & 2 deletions kraken/src/api/handler/attack_results/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub struct SimpleQueryUnhashedResult {
pub hashed_password: Option<String>,

/// An ip address
#[schemars(with = "Option<IpAddr>")] // TODO
#[schemars(with = "Option<IpAddr>")]
pub ip_address: Option<IpNetwork>,

/// A name
Expand Down Expand Up @@ -277,7 +277,7 @@ pub enum DnsTxtScanEntry {
spf_type: DnsTxtScanSpfType,

/// If the txt_type is a SPF type that includes an IP (or whole IP range), it will be set here.
#[schemars(with = "Option<IpAddr>")] // TODO
#[schemars(with = "Option<IpAddr>")]
spf_ip: Option<IpNetwork>,

/// If the txt_type is a SPF type that includes a domain, it will be set here.
Expand Down
28 changes: 1 addition & 27 deletions kraken/src/api/handler/attacks/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ pub struct BruteforceSubdomainsRequest {
pub leech_uuid: Option<Uuid>,

/// Domain to construct subdomains for
// TODO #[schema(example = "example.com")]
pub domain: String,

/// The wordlist to use
pub wordlist_uuid: Uuid,

/// The concurrent task limit
// TODO #[schema(example = 100)]
pub concurrent_limit: u32,

/// The workspace to execute the attack in
Expand All @@ -42,10 +40,8 @@ pub struct BruteforceSubdomainsRequest {
#[serde(untagged)]
pub enum PortOrRange {
/// A single port
// TODO #[schema(example = 8000)]
Port(u16),
/// In inclusive range of ports
// TODO #[schema(value_type = String, example = "1-1024")]
Range(
#[serde(
deserialize_with = "deserialize_port_range",
Expand All @@ -64,17 +60,14 @@ pub struct HostsAliveRequest {
pub leech_uuid: Option<Uuid>,

/// The ip addresses / networks or domains to scan
// TODO #[schema(value_type = Vec<String>, example = json!(["10.13.37.1", "10.13.37.0/24", "google.com"]))]
pub targets: Vec<DomainOrNetwork>,

/// The time to wait until a host is considered down.
///
/// The timeout is specified in milliseconds.
// TODO #[schema(example = 3000)]
pub timeout: u64,

/// The concurrent task limit
// TODO #[schema(example = 30)]
pub concurrent_limit: u32,

/// The workspace to execute the attack in
Expand All @@ -85,21 +78,17 @@ pub struct HostsAliveRequest {
#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone)]
pub struct QueryCertificateTransparencyRequest {
/// Domain to query certificates for
// TODO #[schema(example = "example.com")]
pub target: String,

/// Should expired certificates be included as well
// TODO #[schema(example = true)]
pub include_expired: bool,

/// The number of times the query should be retried if it failed.
// TODO #[schema(example = 3)]
pub max_retries: u32,

/// The interval that should be waited between retries.
///
/// The interval is specified in milliseconds.
// TODO #[schema(example = 500)]
pub retry_interval: u64,

/// The workspace to execute the attack in
Expand All @@ -125,7 +114,6 @@ pub struct ServiceDetectionRequest {
pub leech_uuid: Option<Uuid>,

/// The ip addresses / networks or domains to scan
// TODO #[schema(value_type = Vec<String>, example = json!(["10.13.37.1", "10.13.37.0/24", "google.com"]))]
pub targets: Vec<DomainOrNetwork>,

/// List of single ports and port ranges
Expand All @@ -137,34 +125,28 @@ pub struct ServiceDetectionRequest {
/// The time to wait until a connection is considered failed.
///
/// The timeout is specified in milliseconds.
// TODO #[schema(example = 3000)]
pub connect_timeout: u64,

/// Time to wait for a response after sending the payload
/// (or after establishing a connection, if not payload is to be sent)
///
/// The timeout is specified in milliseconds.
// TODO #[schema(example = 3000)]
pub receive_timeout: u64,

/// The interval that should be wait between retries on a port.
///
/// The interval is specified in milliseconds.
// TODO #[schema(example = 100)]
pub retry_interval: u64,

/// The number of times the connection should be retried if it failed.
// TODO #[schema(example = 2)]
pub max_retries: u32,

/// The concurrent task limit
// TODO #[schema(example = 5000)]
pub concurrent_limit: u32,

/// Skips the initial icmp check.
///
/// All hosts are assumed to be reachable
// TODO #[schema(example = false)]
pub skip_icmp_check: bool,

/// The workspace to execute the attack in
Expand All @@ -191,21 +173,17 @@ pub struct UdpServiceDetectionRequest {
/// The interval that should be wait between retries on a port.
///
/// The interval is specified in milliseconds.
// TODO #[schema(example = 100)]
pub retry_interval: u64,

/// The number of times the connection should be retried if it failed.
// TODO #[schema(example = 2)]
pub max_retries: u32,

/// The time to wait until a connection is considered failed.
///
/// The timeout is specified in milliseconds.
// TODO #[schema(example = 3000)]
pub timeout: u64,

/// The concurrent task limit
// TODO #[schema(example = 5000)]
pub concurrent_limit: u32,

/// The workspace to execute the attack in
Expand Down Expand Up @@ -260,11 +238,9 @@ pub struct DnsResolutionRequest {
pub leech_uuid: Option<Uuid>,

/// The domains to resolve
// TODO #[schemars(example = json!(["example.com", "example.org"]))]
pub targets: Vec<String>,

/// The concurrent task limit
// TODO #[schemars(example = 2)]
pub concurrent_limit: u32,

/// The workspace to execute the attack in
Expand All @@ -280,7 +256,6 @@ pub struct DnsTxtScanRequest {
pub leech_uuid: Option<Uuid>,

/// The domains to resolve
// TODO #[schemars(example = json!(["example.com", "example.org"]))]
pub targets: Vec<String>,

/// The workspace to execute the attack in
Expand Down Expand Up @@ -318,11 +293,10 @@ pub struct ListAttacks {
#[serde(untagged)]
pub enum DomainOrNetwork {
/// A ip address / network
#[schemars(with = "IpAddr")] // TODO
#[schemars(with = "IpAddr")]
Network(IpNetwork),

/// A domain name
// TODO #[schemars(example = "kraken.test")]
Domain(String),
}

Expand Down
4 changes: 0 additions & 4 deletions kraken/src/api/handler/auth/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ use webauthn_rs::prelude::RegisterPublicKeyCredential;
#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone)]
pub struct LoginRequest {
/// The username that should be used for login
// TODO #[schema(example = "user123")]
pub username: String,
/// The password that should be used for login
// TODO #[schema(example = "super-secure-password")]
pub password: String,
}

Expand All @@ -20,10 +18,8 @@ pub struct FinishRegisterRequest {
/// The public key credentials register request
// TODO: provide a example json for this request
#[serde(flatten)]
// TODO #[schema(example = json!({}), value_type = Object)]
#[schemars(with = "serde_json::Value")]
pub register_pk_credential: RegisterPublicKeyCredential,
/// Name of the key
// TODO #[schema(example = "my-security-key-01")]
pub name: String,
}
6 changes: 0 additions & 6 deletions kraken/src/api/handler/common/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ pub struct PathUuid {
#[derive(Copy, Clone, Debug, Deserialize, Serialize, JsonSchema)]
pub struct PageParams {
/// Number of items to retrieve
// TODO #[param(example = 50, minimum = 1)]
pub limit: u64,

/// Position in the whole list to start retrieving from
// TODO #[param(example = 0)]
pub offset: u64,
}

Expand All @@ -41,11 +39,9 @@ pub struct Page<T> {
pub items: Vec<T>,

/// The limit this page was retrieved with
// TODO #[schema(example = 50)]
pub limit: u64,

/// The offset this page was retrieved with
// TODO #[schema(example = 0)]
pub offset: u64,

/// The total number of items this page is a subset of
Expand Down Expand Up @@ -82,7 +78,6 @@ pub struct SimpleTag {
/// Numbers between 2000 and 2999 (inclusive) are server errors.
#[derive(Serialize_repr, Deserialize_repr, JsonSchema_repr, Debug, PartialOrd, PartialEq)]
#[repr(u16)]
// TODO #[schema(default = 1000, example = 1000)]
pub enum ApiStatusCode {
/// Login failed
LoginFailed = 1000,
Expand Down Expand Up @@ -176,7 +171,6 @@ pub struct ApiErrorResponse {
/// The error code
pub status_code: ApiStatusCode,
/// A human readable description of the error
// TODO #[schema(example = "Error message will be here")]
pub message: String,
}

Expand Down
5 changes: 1 addition & 4 deletions kraken/src/api/handler/data_export/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ pub struct AggregatedHost {
pub uuid: Uuid,

/// The IP address of the host.
///
/// If the host has multiple addresses, create a [Host] for each and link them.
#[schemars(with = "IpAddr")] // TODO
pub ip_addr: IpNetwork,
pub ip_addr: IpNetwork, // TODO: this is wrong, should be IpAddr

/// The type of OS of this host
pub os_type: OsType,
Expand Down
5 changes: 0 additions & 5 deletions kraken/src/api/handler/domains/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::models::FindingSeverity;
#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone)]
pub struct CreateDomainRequest {
/// The domain to add
// TODO #[schema(example = "kraken.test")]
pub domain: String,
}

Expand Down Expand Up @@ -53,10 +52,8 @@ pub struct SimpleDomain {
/// The uuid of the domain
pub uuid: Uuid,
/// The domain name
// TODO #[schema(example = "example.com")]
pub domain: String,
/// The comment to the domain
// TODO #[schema(example = "This is a important domain!")]
pub comment: String,
/// The workspace this domain is linked to
pub workspace: Uuid,
Expand All @@ -72,10 +69,8 @@ pub struct FullDomain {
/// The primary key of the domain
pub uuid: Uuid,
/// The domain's name
// TODO #[schema(example = "example.com")]
pub domain: String,
/// A comment
// TODO #[schema(example = "This is a important domain!")]
pub comment: String,
/// The workspace this domain is in
pub workspace: Uuid,
Expand Down
8 changes: 0 additions & 8 deletions kraken/src/api/handler/leeches/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,21 @@ use crate::api::handler::common::de_optional;
#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone)]
pub struct CreateLeechRequest {
/// Name of the leech
// TODO #[schema(example = "leech-01")]
pub name: String,
/// Address of the leech with schema
// TODO #[schema(value_type = String, example = "https://10.13.37:8081")]
pub address: Url,
/// Description of the leech
// TODO #[schema(example = "The first leech in a private net")]
pub description: Option<String>,
}

/// The request to update a leech
#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone)]
pub struct UpdateLeechRequest {
/// Name of the leech
// TODO #[schema(example = "leech-01")]
pub name: Option<String>,
/// Address of the leech
// TODO #[schema(value_type = String, example = "https://10.13.37.1:8081")]
pub address: Option<Url>,
/// Description of the leech
// TODO #[schema(example = "First leech in a private network")]
#[serde(default, deserialize_with = "de_optional")]
pub description: Option<Option<String>>,
}
Expand All @@ -41,10 +35,8 @@ pub struct SimpleLeech {
/// uuid of the leech
pub uuid: Uuid,
/// Name of the leech
// TODO #[schema(example = "leech-01")]
pub name: String,
/// Address of the leech
// TODO #[schema(value_type = String, example = "https://10.13.37.1:8081")]
pub address: Url,
}

Expand Down
Loading

0 comments on commit b71fcb2

Please sign in to comment.