bulwark-cli 0.1.0

Bulwark is a fast, modern, open-source web application security engine.
// TODO: should these strings all be list<u8>?
record request-interface {
  method: string,
  uri: string,
  version: string,
  headers: list<header-interface>,
  chunk: list<u8>,
  chunk-start: u64,
  chunk-length: u64,
  end-of-stream: bool,
}
record response-interface {
  status: u32,
  headers: list<header-interface>,
  chunk: list<u8>,
  chunk-start: u64,
  chunk-length: u64,
  end-of-stream: bool,
}
record header-interface {
  name: string,
  value: list<u8>,
}
variant ip-interface {
  v4(tuple<u8, u8, u8, u8>),
  v6(tuple<u16, u16, u16, u16, u16, u16, u16, u16>),
}
record decision-interface {
  accept: float64,
  restrict: float64,
  unknown: float64,
}
enum outcome-interface {
  restricted,
  suspected,
  accepted,
  trusted,
}
record rate-interface {
  attempts: s64,
  expiration: s64,
}
record breaker-interface {
  generation: s64,
  successes: s64,
  failures: s64,
  consecutive-successes: s64,
  consecutive-failures: s64,
  expiration: s64,
}

// TODO: many of these should return the result type, but the wit-bindgen that the project currently locks to doesn't seem to support it

get-config: func() -> list<u8>
get-param-value: func(key: string) -> list<u8>
set-param-value: func(key: string, value: list<u8>)
get-env-bytes: func(key: string) -> list<u8>

get-request: func() -> request-interface
get-response: func() -> response-interface
get-client-ip: func() -> option<ip-interface>

set-decision: func(decision: decision-interface)
set-tags: func(tags: list<string>)
get-combined-decision: func() -> decision-interface
get-combined-tags: func() -> list<string>
get-outcome: func() -> outcome-interface

get-remote-state: func(key: string) -> list<u8>
set-remote-state: func(key: string, value: list<u8>)
increment-remote-state: func(key: string) -> s64
increment-remote-state-by: func(key: string, delta: s64) -> s64
set-remote-ttl: func(key: string, ttl: s64)

prepare-request: func(method: string, uri: string) -> u64
add-request-header: func(request-id: u64, name: string, value: list<u8>)
set-request-body: func(request-id: u64, body: list<u8>) -> response-interface

increment-rate-limit: func(key: string, delta: s64, window: s64) -> rate-interface
check-rate-limit: func(key: string) -> rate-interface
increment-breaker: func(key: string, success-delta: s64, failure-delta: s64, window: s64) -> breaker-interface
check-breaker: func(key: string) -> breaker-interface