Skip to content

cognitivegears/oashield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

159 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OAShield

OAShield

Turn your OpenAPI spec into a Web Application Firewall that only allows valid API calls.

CI Tests CLI Build License: Apache 2.0 Latest Release

Website · Getting Started · Configuration · Releases


What is OAShield?

OAShield (pronounced like "away shield", /əˈweɪ ʃild/) generates Web Application Firewall (WAF) rules directly from your OpenAPI specification. The generated rules act as a positive security model: they permit exactly the requests your API defines and deny everything else.

It produces standard SecLang rules for both OWASP ModSecurity v3 (libmodsecurity) and Coraza, selectable with a single option.

Why OAShield?

Traditional WAFs rely on pattern matching — a blocklist that tries to recognize known-bad requests. That leaves a gap: anything the patterns haven't seen gets through.

OAShield flips the model. Instead of guessing what's malicious, it uses your OpenAPI spec as the definition of what's valid:

  • Deny by default. If your spec doesn't define a POST /orders, the rules reject every POST /orders request — no signature required.
  • Enforce your contract. Undeclared endpoints, methods, parameters, and request-body fields are blocked. Type and range constraints from the schema are checked.
  • Deploy anywhere SecLang runs. Ship the rules alongside your API or in a sidecar for an extra layer that mirrors your API surface exactly.

Your OpenAPI spec is already the source of truth for your API. OAShield makes it the source of truth for your perimeter too. Curious what the rules look like? See How It Works.

Quick Start

# 1. Get the CLI (or download from Releases)
git clone https://github.com/cognitivegears/oashield.git
cd oashield
mvn package -P build-cli-jar

# 2. Generate rules from your spec
java -cp target/oashield-cli.jar org.openapitools.codegen.OpenAPIGenerator \
  generate -g modsecurity3 \
  -i samples/petstore.yaml \
  -o output/

# 3. Deploy the generated .conf files to your ModSecurity or Coraza setup

Full walkthrough: Getting Started.

Documentation

Guide What's inside
Getting Started Install, generate rules, and deploy them
How It Works What the generated rules do, block by block
Configuration Options, engine flavors, and validation limitations
Integration Testing Running the test suite against real WAF engines

Examples

Sample OpenAPI specs live in samples/, with pre-generated rules in samples/output/petstore/ so you can see what OAShield produces before running it yourself.

Contributing

Issues and pull requests are welcome. Please run mvn test before submitting; see Integration Testing for the full suite.

License

Licensed under the Apache License 2.0. See LICENSE.md.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages