{"id":27969221,"url":"https://github.com/future-architect/code-diaper","last_synced_at":"2025-05-07T21:09:09.954Z","repository":{"id":73504206,"uuid":"199971652","full_name":"future-architect/code-diaper","owner":"future-architect","description":"CodeDiaper is a tool for detecting code leaks.","archived":false,"fork":false,"pushed_at":"2019-08-08T11:22:29.000Z","size":45,"stargazers_count":7,"open_issues_count":8,"forks_count":3,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-07T21:09:04.254Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/future-architect.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":"2019-08-01T03:43:44.000Z","updated_at":"2024-08-12T19:51:34.000Z","dependencies_parsed_at":"2023-08-28T17:46:56.834Z","dependency_job_id":null,"html_url":"https://github.com/future-architect/code-diaper","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/future-architect%2Fcode-diaper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Fcode-diaper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Fcode-diaper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Fcode-diaper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/future-architect","download_url":"https://codeload.github.com/future-architect/code-diaper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252954409,"owners_count":21830905,"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":"2025-05-07T21:09:09.412Z","updated_at":"2025-05-07T21:09:09.928Z","avatar_url":"https://github.com/future-architect.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"CodeDiaper\n====\n\u003cimg src=\"https://img.shields.io/badge/go-v1.12-green.svg\" /\u003e\n\nYou can search for a specific string from all the source code on GitHub and check if it has been posted illegally.\n\n## Usage\n\nThis package uses below services.\n\n* GitHub API\n* Slack API(Optional)\n* Google Cloud Functions(Optional)\n\n## Motivation\n\nI want to detect when a developer accidentally submits a confidential code to GitHub or misconfigures the Public setting.\nCOPYRIGHT is described as a comment of the code in many confidential codes.\nThis tool aims to detect illegal posts by specifying such strings.\nIt seems that this can be achieved using the standard GitHub API, \nbut it only tells you what is contained somewhere in the file. With this tool, you can more accurately detect suspicious code.\n\n\n## QuickStart(Command Line)\n\n### Requirements\n\n* [Go](https://golang.org/dl/) more than 1.11\n\n### Steps\n\n1. Get [GitHub API Token](https://github.blog/2013-05-16-personal-api-tokens/)\n2. Install\n`go get -u github.com/pj-cancan/code-diaper/cmd/codediaper`\n3. Run\n```sh\ncodediaper -githubToken \u003cYour GitHub Token\u003e \\\n  -searchWord=\"Copyright+{2019,2018,2017}+Future+Corporation\" \\\n  -skipOwners=future-architect \\\n  -skipRepos=vuls,ap4r,uroborosql \\\n  -skipLibs=lib/ap4r \\\n  -slackEnabled=false\n```\n4. Result\nYou can see search result. \"Copyright 2019 Future Corporation\", \"Copyright 2018 Future Corporation\", etc.\n\n## QuickStart(Google Cloud Functions)\n\n### Requirements\n\n* [Go](https://golang.org/dl/) more than 1.11\n* [Cloud SDK](https://cloud.google.com/sdk/install/)\n\n### Steps\n\n1. Get [GitHub API Token](https://github.blog/2013-05-16-personal-api-tokens/)\n2. [Get Slack API Token](https://get.slack.help/hc/en-us/articles/215770388-Create-and-regenerate-API-tokens)\n3. Set Cloud Scheduler\n```sh\n# Mac/Linux\ngcloud beta scheduler jobs create pubsub code-diaper --project \u003cYOUR GCP PROJECT\u003e \\\n  --schedule \"55 23 * * *\" \\\n  --topic topic-code-diaper \\\n  --message-body='{\"search\":[{\"word_list\":\"\u003cYOUR SEARCH WORD\u003e\", \"skip_owners\":\u003cYOUR SKIP OWNER LIST\u003e\", skip_repos\":\"\u003cYOUR SKIP LIST\u003e\"}]}' \\\n  --time-zone \"Asia/Tokyo\" \\\n  --description \"This job invokes CloudFunction of code-diaper\"\n\n# Windows\ngcloud beta scheduler jobs create pubsub code-diaper --project \u003cYOUR GCP PROJECT\u003e ^\n  --schedule \"55 23 * * *\" ^\n  --topic topic-code-diaper ^\n  --message-body=\"{\\\"search_list\\\":[{\\\"queries\\\":[\\\"\u003cYOUR SEARCH WORD\u003e\\\"], \"skip_owners\":\u003cYOUR SKIP OWNER LIST\u003e\", \\\"skip_repos\\\":\\\"\u003cYOUR SKIP LIST\u003e\\\"}]}\" ^\n  --time-zone \"Asia/Tokyo\" ^\n  --description \"This job invokes CloudFunction of code-diaper\"\n\n```\n4. Deploy to Cloud Functions\n```sh\ngcloud functions deploy codeDiaper --project \u003cYOUR GCP PROJECT\u003e \\\n  --entry-point Subscribe \\\n  --trigger-resource topic-code-diaper \\\n  --trigger-event google.pubsub.topic.publish \\\n  --timeout=540s \\\n  --runtime go111 \\\n  --set-env-vars GITHUB_API_TOKEN=\u003cgithub-api-token\u003e \\\n  --set-env-vars SLACK_API_TOKEN=\u003cslack-api-token\u003e \\\n  --set-env-vars SLACK_CHANNEL=\u003cslack-channel-name\u003e\n```\n5. Go to the [Cloud Scheduler page](https://cloud.google.com/scheduler/docs/tut-pub-sub) and click the *run now* button of *code-diaper*\n\n\n## Example\n\n// TODO\n\n## Options\n\n| CLI Arg       | Env              | Notes                                         | Type                | Example          |\n|---------------|------------------|-----------------------------------------------|---------------------|------------------|\n| githubToken   | GITHUB_API_TOKEN | GitHub Access Token                           | Required            |                  |\n| searchWord    | SEARCH_WORDS     | GitHub Search word. Comma separated.          | Required            | apple+orange     |\n| skipOwnerList | SKIP_OWNER_LIST  | Skip Owner name list. Comma separated.        | Optional            | future-architect |\n| skipRepoList  | SKIP_REPO_LIST   | Skip repository name list. Comma separated.   | Optional            | repo1,repo2      |\n| skipLibList   | SKIP_LIB_LIST    | Skip library name list. Comma separated.      | Optional            | lib/emoji        |\n| slackEnabled  | ---              | Skip library name list                        | Optional            | true / false     |\n| slackToken    | SLACK_API_TOKEN  | Slack Access Token                            | Optional            |                  |\n| slackChannel  | SLACK_CHANNEL    | Slack Channel ID                              | Optional            |                  |\n\nTips:\n\nThe GitHub API has a limit on the maximum number of searches for a term. Therefore,\nit is necessary to set keywords that will reduce the number of searches as much as possible.\n\nThis is a trade-off. If too many keywords are set, there is a risk of missing leaked codes.\n\nIf there are many false positives, you can exclude them by adding a skip list.\n\n\n## Developer Guide\n\nInstall git pre-commit hook script before developing.\n\n```bash\n# Windows\ngit clone https://github.com/pj-cancan/code-diaper\ncopy /Y .\\githooks\\*.* .\\.git\\hooks\n\n# Mac/Linux\ngit clone https://github.com/pj-cancan/code-diaper\ncp githooks/* .git/hooks\nchmod +x .git/hooks/pre-commit\n```\n\n## License\n\nThis project is licensed under the Apache License 2.0 License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuture-architect%2Fcode-diaper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuture-architect%2Fcode-diaper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuture-architect%2Fcode-diaper/lists"}