{"id":21477474,"url":"https://github.com/spectralops/service-policy-kit","last_synced_at":"2025-07-15T10:33:21.934Z","repository":{"id":43073703,"uuid":"413016587","full_name":"SpectralOps/service-policy-kit","owner":"SpectralOps","description":"service_policy_kit is a Rust based toolkit for verifying HTTP services against policies.","archived":false,"fork":false,"pushed_at":"2024-05-19T08:26:31.000Z","size":175,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-17T10:52:22.787Z","etag":null,"topics":["rust","rust-lang","security","testing"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SpectralOps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2021-10-03T08:13:50.000Z","updated_at":"2024-05-19T08:26:34.000Z","dependencies_parsed_at":"2024-05-19T07:23:50.712Z","dependency_job_id":"c35c4fd8-7fd3-4906-85fd-b4d47bd81367","html_url":"https://github.com/SpectralOps/service-policy-kit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectralOps%2Fservice-policy-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectralOps%2Fservice-policy-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectralOps%2Fservice-policy-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectralOps%2Fservice-policy-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpectralOps","download_url":"https://codeload.github.com/SpectralOps/service-policy-kit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226033251,"owners_count":17563126,"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":["rust","rust-lang","security","testing"],"created_at":"2024-11-23T11:13:45.431Z","updated_at":"2024-11-23T11:13:45.922Z","avatar_url":"https://github.com/SpectralOps.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n   \u003cimg src=\"media/spk.png\" width=\"355\"/\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003chr/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/spectralops/service-policy-kit/actions/workflows/build.yml/badge.svg\"/\u003e\n\n\u003c/p\u003e\n\n# Service Policy Kit\n\n`service_policy_kit` is a Rust based toolkit for verifying HTTP services against policies. You can:\n\n* Build a complete testing framework on your own, with `service_policy_kit` taking care of all the expectation logic\n* Run fuzzing tests against your services\n* Integrate in your code to perform custom readiness/self checks\n* Build your own tools (CLIs) that perform service validation and security testing of different kinds\n\n## Quick Start\n\nAdd to `Cargo.toml`\n\n\n```ini\nservice_policy_kit = \"0.2.0\"\n```\n\n## Example\n\nHere's a full-blown policy runner that you can reuse:\n\n```rust\nuse serde_yaml;\nuse service_policy_kit::data::{Context, SequenceInteractions};\nuse service_policy_kit::runner::{RunOptions, SequenceRunner};\nuse std::process::exit;\n\nfn main() {\n    let opts = RunOptions::default();\n    let runner = SequenceRunner::from_opts(\u0026opts);\n\n    let sequence: SequenceInteractions = serde_yaml::from_str(\n        r#\"\nhttp_interactions:\n- request:\n    id: step one\n    uri: http://example.com\n  response:\n    status_code: \"200\"\n\"#,\n    )\n    .unwrap();\n    let mut context = Context::new();\n    let res = runner.run(\u0026mut context, \u0026sequence.http_interactions);\n    exit(if res.ok { 0 } else { 1 })\n}\n```\n\nYou can run it by cloning this repo, and then:\n\n```\ncargo run --example quick-start\n```\n\nYou should get:\n\n```yaml\n$ cargo run --examples quick-start\n\n✔ step one: ok 288ms\n\nRan 1 interactions with 1 checks in 288ms\n\nSuccess: 1\nFailure: 0\n  Error: 0\nSkipped: 0\n```\n\n\n## Capabilities\n\n* :white_check_mark: \u0026nbsp;Flexible design: Use the runner for any purpose, sequence or individual interactions\n* :white_check_mark: \u0026nbsp;Contextual flows: interactions can extract, define and pass variables to the next ones\n* :white_check_mark: \u0026nbsp;Out of the box reporters: saves you some boilerplate work\nMultiple checks included: content, benchmark, certificates\n* :white_check_mark: \u0026nbsp;Discovery (WIP): given recorded API interactions, or an API spec, automatically generate interactions.\n\n\n## Concepts\n\nThere are a few concepts that make up `service_policy_kit`: `Interaction`, `Expectation`, `Check`, `Violation` and `Runners`.\n\n### Interaction\n\nAn interaction is a definition of calling an external service, and the expected responses per check type.\n\n```rust\nInteraction {\n   request,\n   response,\n   examples,\n   benchmark,\n   cert,\n}\n```\n\n### Expectation (Policy)\n\nAn expectation is a set of expected matchers for all of the parts that are extracted from an interaction response.\n\n\nEach of the fields take regular expressions and are matched against a live response accordingly.\n\n```rust\nResponse {\n   headers,\n   status_code,\n   body,\n   vars,\n}\n```\n\n\n\n### Check\n\nA check is an abstract action over a response. For example, running content expectation, a benchmark, or any other policy against a service.\n\n\n### Violation\n\nAny check can output violation. A successful check has no violations.\n### Runners\n\nA runner takes a set of _interactions_ and execute these. For example, the included `SequenceRunner` will always execute interactions in a sequence, extracting variables from one interaction and passing it to the next one via `Context`.\n\n# Thanks\n\nTo all [Contributors](https://github.com/spectralops/service-policy-kit/graphs/contributors) - you make this happen, thanks!\n\n\n# Copyright\n\nCopyright (c) 2021 [@jondot](http://twitter.com/jondot). See [LICENSE](LICENSE.txt) for further details.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspectralops%2Fservice-policy-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspectralops%2Fservice-policy-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspectralops%2Fservice-policy-kit/lists"}