{"id":22940945,"url":"https://github.com/envylabs/rubycop","last_synced_at":"2025-11-11T20:36:52.152Z","repository":{"id":1528794,"uuid":"1805961","full_name":"envylabs/RubyCop","owner":"envylabs","description":null,"archived":false,"fork":false,"pushed_at":"2012-06-16T19:40:44.000Z","size":168,"stargazers_count":33,"open_issues_count":5,"forks_count":8,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-03-25T23:03:55.360Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"spree/spree","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/envylabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-05-26T18:47:16.000Z","updated_at":"2021-04-14T12:33:06.000Z","dependencies_parsed_at":"2022-07-08T05:02:34.700Z","dependency_job_id":null,"html_url":"https://github.com/envylabs/RubyCop","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envylabs%2FRubyCop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envylabs%2FRubyCop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envylabs%2FRubyCop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envylabs%2FRubyCop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/envylabs","download_url":"https://codeload.github.com/envylabs/RubyCop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229708316,"owners_count":18111250,"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":[],"created_at":"2024-12-14T13:33:36.852Z","updated_at":"2025-10-11T09:42:15.566Z","avatar_url":"https://github.com/envylabs.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"RubyCop\n\nRubyCop scans Ruby code and tells you whether it's safe or not. We use\nit at [CodeSchool][1] to check user-submitted code before we eval it on\nthe server.\n\nRubyCop is made up of two pieces: NodeBuilder and Policy. NodeBuilder is\nresponsible for parsing Ruby code (using Ripper) and building an AST\n(Abstract Syntax Tree). Policy then scans the AST and tells you whether\nthe code is safe or not.\n\n## Requirements\n\nRubyCop requires Ruby 1.9, though it should work under 1.8 if you\ninclude the \"ripper\" gem.\n\n## Usage\n\nHere's a quick example of building the AST, and evaluating it with the\nPolicy:\n\n    \u003e\u003e require \"ruby_cop\"\n    =\u003e true\n    \u003e\u003e policy = RubyCop::Policy.new\n    \u003e\u003e ast = RubyCop::NodeBuilder.build(\"x = 1 + 2\")\n    \u003e\u003e ast.accept(policy)\n    =\u003e true\n\nAnd if you pass in some unsafe code:\n\n    \u003e\u003e ast = RubyCop::NodeBuilder.build(\"x = `ls -la`\")\n    \u003e\u003e ast.accept(policy)\n    =\u003e false\n\n## Drawbacks\n\nRuby is a very dynamic language, so this kind of static analysis will\nonly get you so far. RubyCop blocks obvious things like backticks and\nunsafe Kernel methods (#eval, #exec, #fork, etc.), but has to err on the\nside of safety in other places. For instance, #send is considered\nunsafe.\n\n[1]: http://www.codeschool.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenvylabs%2Frubycop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenvylabs%2Frubycop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenvylabs%2Frubycop/lists"}