{"id":18447785,"url":"https://github.com/stoplightio/spectral-owasp-ruleset","last_synced_at":"2025-04-12T14:55:31.234Z","repository":{"id":60276052,"uuid":"528967945","full_name":"stoplightio/spectral-owasp-ruleset","owner":"stoplightio","description":"Improve the security of your API by detecting common vulnerabilities as defined by OWASP and enforced with Spectral.","archived":false,"fork":false,"pushed_at":"2024-11-13T21:46:12.000Z","size":617,"stargazers_count":75,"open_issues_count":12,"forks_count":15,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-05T22:43:22.126Z","etag":null,"topics":["api","hacktoberfest","openapi","openapi3","openapi31","security"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stoplightio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-25T18:14:13.000Z","updated_at":"2025-03-17T01:08:48.000Z","dependencies_parsed_at":"2024-06-18T22:43:36.325Z","dependency_job_id":"f30343f7-7a67-44f8-8770-4d27a63c59de","html_url":"https://github.com/stoplightio/spectral-owasp-ruleset","commit_stats":{"total_commits":51,"total_committers":8,"mean_commits":6.375,"dds":"0.33333333333333337","last_synced_commit":"624d67f3a124de36502ad3d06c35917da19dff85"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoplightio%2Fspectral-owasp-ruleset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoplightio%2Fspectral-owasp-ruleset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoplightio%2Fspectral-owasp-ruleset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoplightio%2Fspectral-owasp-ruleset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stoplightio","download_url":"https://codeload.github.com/stoplightio/spectral-owasp-ruleset/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586243,"owners_count":21128995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","hacktoberfest","openapi","openapi3","openapi31","security"],"created_at":"2024-11-06T07:14:26.201Z","updated_at":"2025-04-12T14:55:31.205Z","avatar_url":"https://github.com/stoplightio.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Spectral OWASP API Security\n\n[![NPM Downloads](https://img.shields.io/npm/dw/@stoplight/spectral-owasp-ruleset?color=blue)](https://www.npmjs.com/package/@stoplight/spectral-owasp-ruleset) [![Stoplight Forest](https://img.shields.io/ecologi/trees/stoplightinc)][stoplight_forest]\n\nScan an [OpenAPI](https://spec.openapis.org/oas/v3.1.0) document to detect security issues. As OpenAPI is only describing the surface level of the API it cannot see what is happening in your code, but it can spot obvious issues and outdated standards being used.\n\nv2.x of this ruleset is based on the [OWASP API Security Top 10 2023 edition](https://owasp.org/API-Security/editions/2023/en/0x00-header/), but if you would like to use the [2019 edition](https://owasp.org/API-Security/editions/2019/en/0x00-header/) please use v1.x.\n\n## Installation\n\n```bash\nnpm install --save -D @stoplight/spectral-owasp-ruleset@^2.0\nnpm install --save -D @stoplight/spectral-cli\n```\n\n## Usage\n\nCreate a local ruleset that extends the ruleset. In its most basic form this just tells Spectral what ruleset you want to use, but it will allow you to customise things, add your own rules, turn bits off if its causing trouble.\n\n```\ncd ~/src/\u003cyour-api\u003e\n\necho 'extends: [\"@stoplight/spectral-owasp-ruleset\"]' \u003e .spectral.yaml\n```\n\n_If you're using VS Code or Stoplight Studio then the NPM modules will not be available. Instead you can use the CDN hosted version:_\n\n```\necho 'extends: [\"https://unpkg.com/@stoplight/spectral-owasp-ruleset/dist/ruleset.mjs\"]' \u003e .spectral.yaml\n```\n\n_**Note:** You need to use the full URL with CDN hosted rulesets because Spectral [cannot follow redirects through extends](https://github.com/stoplightio/spectral/issues/2266)._\n\nNext, use Spectral CLI to lint against your OpenAPI description. Don't have any OpenAPI? [Record some HTTP traffic to make OpenAPI](https://apisyouwonthate.com/blog/creating-openapi-from-http-traffic) and then you can switch to API Design-First going forwards.\n\n```\nspectral lint api/openapi.yaml\n```\n\nYou should see some output like this:\n\n```\n/Users/phil/src/protect-earth-api/api/openapi.yaml\n  4:5        error    owasp:api8:2023-inventory-access            Declare intended audience of every server by defining servers[0].x-internal as true/false.  servers[0]\n  4:10       error    owasp:api8:2023-no-server-http              Server URLs must not use http://. https:// is highly recommended.                        servers[0].url\n  45:15        error  owasp:api4:2023-rate-limit                  All 2XX and 4XX responses should define rate limiting headers.  paths./upload.post.responses[201]\n  47:15        error  owasp:api4:2023-rate-limit                  All 2XX and 4XX responses should define rate limiting headers.  paths./upload.post.responses[401]\n  93:16  information  owasp:api2:2023-read-restricted             This operation is not protected by any security scheme.  paths./sites.get.security\n 210:16  information  owasp:api2:2023-read-restricted             This operation is not protected by any security scheme.  paths./species.get.security\n```\n\nNow you have some things to work on for your API. Thankfully these are only at the `warning` and `information` severity, and that is not going to [fail continuous integration](https://docs.stoplight.io/docs/spectral/ZG9jOjExNTMyOTAx-continuous-integration) (unless [you want them to](https://docs.stoplight.io/docs/spectral/ZG9jOjI1MTg1-spectral-cli#error-results)).\n\nThere are [a bunch of other rulesets](https://github.com/stoplightio/spectral-rulesets) or [Stoplight API Stylebook](http://apistylebook.stoplight.io) you can use, or use for inspiration for your own rulesets and API Style Guides.\n\n## 🎉 Thanks\n\n- [Andrzej](https://github.com/jerzyn) - Great rules contributed to the Adidas style guide.\n- [Roberto Polli](https://github.com/ioggstream) - Created lots of excellent Spectral rules for [API OAS Checker](https://github.com/italia/api-oas-checker/) which aligned with the OWASP API rules.\n\n## 📜 License\n\nThis repository is licensed under the MIT license.\n\n## 🌲 Sponsor\n\nIf you would like to thank us for creating Spectral, we ask that you [**buy the world a tree**][stoplight_forest].\n\n[stoplight_forest]: https://ecologi.com/stoplightinc\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoplightio%2Fspectral-owasp-ruleset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstoplightio%2Fspectral-owasp-ruleset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoplightio%2Fspectral-owasp-ruleset/lists"}