{"id":20851648,"url":"https://github.com/emsk/mask_sql","last_synced_at":"2025-05-12T04:32:15.919Z","repository":{"id":56882883,"uuid":"87436322","full_name":"emsk/mask_sql","owner":"emsk","description":"A command-line tool to mask sensitive values in a SQL file","archived":false,"fork":false,"pushed_at":"2021-06-20T08:04:29.000Z","size":94,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-13T06:22:19.753Z","etag":null,"topics":["cli","gem","ruby","sql"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emsk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-06T14:06:42.000Z","updated_at":"2022-08-20T11:01:17.000Z","dependencies_parsed_at":"2022-08-20T22:31:00.161Z","dependency_job_id":null,"html_url":"https://github.com/emsk/mask_sql","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emsk%2Fmask_sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emsk%2Fmask_sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emsk%2Fmask_sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emsk%2Fmask_sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emsk","download_url":"https://codeload.github.com/emsk/mask_sql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225119935,"owners_count":17423818,"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":["cli","gem","ruby","sql"],"created_at":"2024-11-18T03:14:27.149Z","updated_at":"2024-11-18T03:14:27.794Z","avatar_url":"https://github.com/emsk.png","language":"Ruby","readme":"# MaskSQL\n\n[![Gem Version](https://badge.fury.io/rb/mask_sql.svg)](https://badge.fury.io/rb/mask_sql)\n[![Build Status](https://github.com/emsk/mask_sql/actions/workflows/build.yml/badge.svg)](https://github.com/emsk/mask_sql/actions/workflows/build.yml)\n[![Build Status](https://travis-ci.org/emsk/mask_sql.svg?branch=main)](https://travis-ci.org/emsk/mask_sql)\n[![Build Status](https://dev.azure.com/emsk/mask_sql/_apis/build/status/emsk.mask_sql?branchName=main)](https://dev.azure.com/emsk/mask_sql/_build/latest?definitionId=5\u0026branchName=main)\n[![Codecov](https://codecov.io/gh/emsk/mask_sql/branch/main/graph/badge.svg)](https://codecov.io/gh/emsk/mask_sql)\n[![Code Climate](https://codeclimate.com/github/emsk/mask_sql/badges/gpa.svg)](https://codeclimate.com/github/emsk/mask_sql)\n[![Inline docs](http://inch-ci.org/github/emsk/mask_sql.svg?branch=main)](http://inch-ci.org/github/emsk/mask_sql)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt)\n\nMaskSQL is a command-line tool to mask sensitive values in a SQL file.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'mask_sql'\n```\n\nAnd then execute:\n\n```sh\n$ bundle\n```\n\nOr install it yourself as:\n\n```sh\n$ gem install mask_sql\n```\n\n## Usage\n\n### Mask sensitive values in a SQL file\n\n```sh\n$ mask_sql --in dump.sql --out masked_dump.sql --config mask_config.yml\n```\n\n### Generate a config file\n\n```sh\n$ mask_sql init\n```\n\n## Command Options\n\n| Option | Alias | Description | Default |\n| :----- | :---- | :---------- | :------ |\n| `--in` | `-i` | Input file path (Required). | |\n| `--out` | `-o` | Output file path (Required). | |\n| `--config` | `-c` | Config YAML file path. | `.mask.yml` in the working directory. |\n| `--insert` | | `true` if mask `INSERT` SQL. | `false`, but `true` if `--insert`, `--replace`, and `--copy` options are not given. |\n| `--replace` | | `true` if mask `REPLACE` SQL. | `false`, but `true` if `--insert`, `--replace`, and `--copy` options are not given. |\n| `--copy` | | `true` if mask `COPY` SQL. | `false`, but `true` if `--insert`, `--replace`, and `--copy` options are not given. |\n\n## Config\n\nThe following keys are available in the config YAML file.\n\n### Top level keys\n\n| Key | Description | Type |\n| :-- | :---------- | :--- |\n| `mark` | Replacement text. | String |\n| `targets` | Array of targets. | Array |\n\n### Keys for `targets`\n\n| Key | Description | Type |\n| :-- | :---------- | :--- |\n| `table` | Target table name. | String |\n| `columns` | Columns count of the table. | Integer |\n| `dummy_values` | Target column index (zero-based) and dummy text. | Hash |\n| `group_indexes` | Array of column indexes (zero-based).\u003cbr\u003eRecords that have the same values in these indexes are considered as the same numbering group. | Array |\n\n## Examples\n\nInput file (includes sensitive values):\n\n```sql\nINSERT INTO `people` (`id`, `code`, `name`, `email`) VALUES (1,'01','坂本龍馬','ryoma-sakamoto@example.com'),(2,'02','高杉晋作','shinsaku-takasugi@example.com'),(3,'03','沖田総司','soji-okita@example.com');\nINSERT INTO `cats` (`code`, `name`) VALUES ('01','Sora'),('02','Hana'),('03','Leo');\nINSERT INTO `dogs` (`code`, `name`, `house_id`, `room_id`) VALUES ('01','Pochi',1,1),('02','Rose',2,1),('03','Momo',1,1),('04','Sakura',1,2);\n\nREPLACE INTO `people` (`id`, `code`, `name`, `email`) VALUES (1,'01','坂本龍馬','ryoma-sakamoto@example.com'),(2,'02','高杉晋作','shinsaku-takasugi@example.com'),(3,'03','沖田総司','soji-okita@example.com');\nREPLACE INTO `cats` (`code`, `name`) VALUES ('01','Sora'),('02','Hana'),('03','Leo');\nREPLACE INTO `dogs` (`code`, `name`, `house_id`, `room_id`) VALUES ('01','Pochi',1,1),('02','Rose',2,1),('03','Momo',1,1),('04','Sakura',1,2);\n\nCOPY people (id, code, name, email) FROM stdin;\n1\t01\t坂本龍馬\tryoma-sakamoto@example.com\n2\t02\t高杉晋作\tshinsaku-takasugi@example.com\n3\t03\t沖田総司\tsoji-okita@example.com\n\\.\nCOPY cats (code, name) FROM stdin;\n01\tSora\n02\tHana\n03\tLeo\n\\.\nCOPY dogs (code, name, house_id, room_id) FROM stdin;\n01\tPochi\t1\t1\n02\tRose\t2\t1\n03\tMomo\t1\t1\n04\tSakura\t1\t2\n\\.\n```\n\nOutput file (the sensitive values are masked):\n\n```sql\nINSERT INTO `people` (`id`, `code`, `name`, `email`) VALUES (1,'01','氏名1','email-1@example.com'),(2,'02','氏名2','email-2@example.com'),(3,'03','氏名3','email-3@example.com');\nINSERT INTO `cats` (`code`, `name`) VALUES ('code-1','Cat name 1'),('code-2','Cat name 2'),('code-3','Cat name 3');\nINSERT INTO `dogs` (`code`, `name`, `house_id`, `room_id`) VALUES ('code-1','Dog name 1',1,1),('code-1','Dog name 1',2,1),('code-2','Dog name 2',1,1),('code-1','Dog name 1',1,2);\n\nREPLACE INTO `people` (`id`, `code`, `name`, `email`) VALUES (1,'01','氏名1','email-1@example.com'),(2,'02','氏名2','email-2@example.com'),(3,'03','氏名3','email-3@example.com');\nREPLACE INTO `cats` (`code`, `name`) VALUES ('code-1','Cat name 1'),('code-2','Cat name 2'),('code-3','Cat name 3');\nREPLACE INTO `dogs` (`code`, `name`, `house_id`, `room_id`) VALUES ('code-1','Dog name 1',1,1),('code-1','Dog name 1',2,1),('code-2','Dog name 2',1,1),('code-1','Dog name 1',1,2);\n\nCOPY people (id, code, name, email) FROM stdin;\n1\t01\t氏名1\temail-1@example.com\n2\t02\t氏名2\temail-2@example.com\n3\t03\t氏名3\temail-3@example.com\n\\.\nCOPY cats (code, name) FROM stdin;\ncode-1\tCat name 1\ncode-2\tCat name 2\ncode-3\tCat name 3\n\\.\nCOPY dogs (code, name, house_id, room_id) FROM stdin;\ncode-1\tDog name 1\t1\t1\ncode-1\tDog name 1\t2\t1\ncode-2\tDog name 2\t1\t1\ncode-1\tDog name 1\t1\t2\n\\.\n```\n\nConfig file:\n\n```yaml\nmark: '[mask]'\ntargets:\n  - table: people\n    columns: 4\n    dummy_values:\n      2: 氏名[mask]\n      3: email-[mask]@example.com\n  - table: cats\n    columns: 2\n    dummy_values:\n      0: code-[mask]\n      1: Cat name [mask]\n  - table: dogs\n    columns: 4\n    dummy_values:\n      0: code-[mask]\n      1: Dog name [mask]\n    group_indexes:\n      - 2\n      - 3\n```\n\n## Supported Ruby Versions\n\nRuby 2.0.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0\n\n## Contributing\n\nBug reports and pull requests are welcome.\n\n## Related\n\n* [mruby-masksql](https://github.com/emsk/mruby-masksql) - An mruby implementation of the mask_sql\n\n## License\n\n[MIT](LICENSE.txt)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femsk%2Fmask_sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femsk%2Fmask_sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femsk%2Fmask_sql/lists"}