{"id":20129321,"url":"https://github.com/aicore/secrets-detector","last_synced_at":"2025-04-09T16:09:09.686Z","repository":{"id":39581279,"uuid":"455168643","full_name":"aicore/secrets-detector","owner":"aicore","description":"Pure node secrets detection library.","archived":false,"fork":false,"pushed_at":"2025-04-08T10:49:42.000Z","size":143,"stargazers_count":0,"open_issues_count":16,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-09T16:09:05.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aicore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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-02-03T13:06:58.000Z","updated_at":"2022-02-03T13:58:01.000Z","dependencies_parsed_at":"2023-09-27T16:39:01.435Z","dependency_job_id":"fe50e87f-f9e5-4f48-8145-aaa200d2525d","html_url":"https://github.com/aicore/secrets-detector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"aicore/template-nodejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aicore%2Fsecrets-detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aicore%2Fsecrets-detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aicore%2Fsecrets-detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aicore%2Fsecrets-detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aicore","download_url":"https://codeload.github.com/aicore/secrets-detector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065283,"owners_count":21041871,"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-11-13T20:33:34.186Z","updated_at":"2025-04-09T16:09:09.662Z","avatar_url":"https://github.com/aicore.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Secrets-scanner\nSecrets detector is a tool that finds secrets like AWS keys, API secrets, and tokens. It does so by looking at all the files in the current folder and attempting to match them against a list of secret signatures.\n\nSecrets scanner is a stand-alone package written purely in node-js and does not have any dependency on python or other secret scanner utilities.\n\n## How to install\nTo install the secrets scanner globally, run the following command in the terminal.\n\n```shell\nnpm install -g secrets-scanner\n```\nIf you have to install it as a development time utility.\n```shell\nnpm install --save-dev secrets-scanner\n```\n\n# How to execute\nTo execute the secrets scanning tool on a specific folder, run the following command in the terminal:\n```shell\nsecrets-scanner\n```\n* The scanner will check for secrets in all files in the current folder recursively.\n\n* The scanner will honor and ignore all files specified in .gitignore file.\n  On completion, the command will succeed if it did not find any secrets.\n\nIf any secrets are detected, the command will exit with -1 and the offending secrets will be displayed:\n```shell\nsecrets-scanner\nError! Secrets Detected in the following files:\nsrc/a.json, line 32, col 21: password: pass\ntest/a.html, line 2, col 1: awsaccesskey: 23\n```\n\n# Ignoring false positives\nSometimes, the secret scanner may flag a line as offending, but it might be an essential component of code. In such cases, we can selectively specify secret scanner to ignore a specific line by placing a comment secrets-ignore above the offending line.\n\nFor eg. In a file below test.js , password=”pass” can be ignored by adding a line comment above the code as follows:\n```shell\n...\nfunction test(){\n  //secrets-ignore\n  let password = \"pass\";\n  ...\n}\n...\n```\n## Other Languages\n```shell\nFor python, bash:\n\n#secrets-ignore\npassword=\"pass\"\n\nHTML:\n\u003c!-- secrets-ignore --\u003e\npassword=\"pass\"\n\nCSS:\n/* secrets-ignore */\n\nJSON:\nuse additional configuration file below to exclude json keys from secret scanner.\n\n```\n\n## Additional configuration\nCreate a file secrets-scanner.json to specify additional configuration options.  The configuration options are listed below:\n```shell\n{\n \"version\": 1,\n \"gitIgnore\": [true|false], // weather to honor git-ignore or not.\n \"jsonIgnore\": {\n   // https://stackoverflow.com/questions/8481380/is-there-a-json-equivalent-of-xquery-xpath\n   \"\u003cfile path1\u003e\": [\"\u003cjsonpath of key 1\u003e\", \"jsonpath of key 2\"...]\n }\n}\n```\n\n## jsonIgnore\nSince JSON does not support inline comments to ignore false positives, the configuration file can be used to ignore specific json keys. For example, consider the following json files:\n```shell\n// a.json\n{\"login\":{\n   \"pass\": \"pass\"\n}}\n// src/b.json\n{\"login\":{\n   \"user\":{\"pass\": \"pass\"}\n}}\n```\nThe secrets can be whitelisted using the following  secrets-scanner.json configuration file:\n```shell\n{\n \"version\": 1,\n \"gitIgnore\": [true|false], // weather to honor git-ignore or not.\n \"jsonIgnore\": {\n   \"a.json\": [\"login.pass\"],\n   \"src/b.json\": [\"login.user.pass\"]\n }\n}\n```\n\n## Supported languages\nThe following language files will be scanned for secrets:\n```shell\n1.HTML\n2.JS\n```\n## Development notes\nThis section is relevant only if you are developing or making changes to the secrets-scanner itself.\n\n## Testing\nTo run all tests:\n```shell\n\u003e npm run test\n  Hello world Tests\n    ✔ should return Hello World\n    #indexOf()\n      ✔ should return -1 when the value is not present\n```\nAdditionally, to run unit/integration tests only, use the commands:\n```shell\n\u003e npm run test:unit\n\u003e npm run test:integ\n```\n## Coverage Reports\nTo run all tests with coverage:\n\n```shell\n\u003e npm run cover\n  Hello world Tests\n    ✔ should return Hello World\n    #indexOf()\n      ✔ should return -1 when the value is not present\n\n\n  2 passing (6ms)\n\n----------|---------|----------|---------|---------|-------------------\nFile      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s \n----------|---------|----------|---------|---------|-------------------\nAll files |     100 |      100 |     100 |     100 |                   \n backup.js |     100 |      100 |     100 |     100 |                   \n----------|---------|----------|---------|---------|-------------------\n\n=============================== Coverage summary ===============================\nStatements   : 100% ( 5/5 )\nBranches     : 100% ( 2/2 )\nFunctions    : 100% ( 1/1 )\nLines        : 100% ( 5/5 )\n================================================================================\nDetailed unit test coverage report: file:///template-nodejs/coverage-unit/index.html\nDetailed integration test coverage report: file:///template-nodejs/coverage-integration/index.html\n```\nAfter running coverage, detailed reports can be found in the coverage folder listed in the output of coverage command.\nOpen the file in browser to view detailed reports.\n\nTo run unit/integration tests only with coverage\n```shell\n\u003e npm run cover:unit\n\u003e npm run cover:integ\n```\n\nSample coverage report:\n![image](https://user-images.githubusercontent.com/5336369/148687351-6d6c12a2-a232-433d-ab62-2cf5d39c96bd.png)\n\n### Unit and Integration coverage configs\nUnit and integration test coverage settings can be updated by configs `.nycrc.unit.json` and `.nycrc.integration.json`.\n\nSee https://github.com/istanbuljs/nyc for config options.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faicore%2Fsecrets-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faicore%2Fsecrets-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faicore%2Fsecrets-detector/lists"}