{"id":19628170,"url":"https://github.com/gr455/contain","last_synced_at":"2026-05-11T12:33:58.505Z","repository":{"id":159844495,"uuid":"629587442","full_name":"gr455/contain","owner":"gr455","description":"BPF based per-process per-container egress filter","archived":false,"fork":false,"pushed_at":"2024-01-27T01:55:48.000Z","size":116,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-26T20:23:23.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gr455.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-04-18T15:58:25.000Z","updated_at":"2024-02-09T10:43:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"c779f8e4-75e3-400d-b8e7-f9e75cf2dd21","html_url":"https://github.com/gr455/contain","commit_stats":null,"previous_names":["gr455/contain"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gr455/contain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr455%2Fcontain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr455%2Fcontain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr455%2Fcontain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr455%2Fcontain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gr455","download_url":"https://codeload.github.com/gr455/contain/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr455%2Fcontain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32894838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-10T13:40:02.631Z","status":"online","status_checked_at":"2026-05-11T02:00:05.975Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-11T11:54:21.021Z","updated_at":"2026-05-11T12:33:58.489Z","avatar_url":"https://github.com/gr455.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Contain\nBPF based per-process per-container egress filter.\n\nFilters outgoing traffic from containers based on the container and the process the traffic originated from. Once containd is running, it automatically detects any new containers.\n\n## Run\n\n**Requires cgroup v2**\n\n1. Update `blacklist.json` with your own allow list.\n\n2. To start Contain daemon, run\n```\npython3 containd.py\n```\n\nWhen the daemon is running, it detects any newly started containers and applies policies to them.\n\nOnce started, the allow list\n\n```json\n[\n\t{\t\n\t\t\"container_name\": \"curler\", // Only add a single object per container\n\t\t\"policy\": [\n\t\t\t{\n\t\t\t\t\"process\": \"curl\", // Only add a single object per process, add one/multiple objects per container\n\t\t\t\t\"allow\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"cidr4\": \"1.1.1.0/24\",\n\t\t\t\t\t\t\"ports\": [80, 443]\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t}\n]\n\n```\n\nGives\n\n![Result](images/example.png)\n\nThis BPF filter uses `BPF_PROG_TYPE_CGROUP_SKB` and a kretprobe to kernel function `net/socket/sock_alloc_file` for per-process, per-container socket filtering.\n\nTested on Linux 5.19.0 - 6.2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr455%2Fcontain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgr455%2Fcontain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr455%2Fcontain/lists"}