{"id":13413783,"url":"https://github.com/avahidi/interpol","last_synced_at":"2026-01-26T14:03:33.256Z","repository":{"id":57704226,"uuid":"445455077","full_name":"avahidi/interpol","owner":"avahidi","description":"The \"interpol\" security string interpolation library and the \"police\" command line tool. Just moved here from https://bitbucket.org/vahidi/interpol","archived":false,"fork":false,"pushed_at":"2025-07-05T16:27:00.000Z","size":105,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-05T18:03:43.734Z","etag":null,"topics":["golang","security-tools"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avahidi.png","metadata":{"files":{"readme":"README.rst","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}},"created_at":"2022-01-07T08:45:50.000Z","updated_at":"2025-07-05T16:27:03.000Z","dependencies_parsed_at":"2022-09-26T21:12:07.327Z","dependency_job_id":null,"html_url":"https://github.com/avahidi/interpol","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/avahidi/interpol","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avahidi%2Finterpol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avahidi%2Finterpol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avahidi%2Finterpol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avahidi%2Finterpol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avahidi","download_url":"https://codeload.github.com/avahidi/interpol/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avahidi%2Finterpol/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28780058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T13:55:28.044Z","status":"ssl_error","status_checked_at":"2026-01-26T13:55:26.068Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["golang","security-tools"],"created_at":"2024-07-30T20:01:49.218Z","updated_at":"2026-01-26T14:03:33.244Z","avatar_url":"https://github.com/avahidi.png","language":"Go","readme":".. image:: logo.png\n   :align: center\n\nInterpol\n========\n\n**Interpol** is a minimal, rule-based `string interpolation \u003chttps://en.wikipedia.org/wiki/String_interpolation\u003e`_ library for Go. It is designed for generating data that follows a specific format, such as test data, password corpuses, or any structured text.\n\nA command-line utility, `police`, is also provided for standalone use.\n\nExample\n-------\n\nAssume you have forgotten your password for the company mainframe. You do however remember that the password had the following structure: `\u003ca character from the show Friends\u003e\u003ca digit\u003e\u003ca currency symbol\u003e`.\n\nUsing Interpol, we can generate a list of all such combinations:\n\n1.  Create a file named `friends.txt` containing the characters' names.\n2.  Run `police` with the following rules:\n\n.. code-block:: bash\n\n    $ police \"{{file filename='friends.txt'}}{{counter min=0 max=9}}{{set data='£$¥€'}}\"\n\nThe generated output can be used with a password recovery tool such as `john` to quickly find your lost password.\n\n.. code-block::\n    \n    Rachel0£\n    Monica0£\n    Phoebe0£\n    ...\n    Joey9€\n    Chandler9€\n    Gunther9€\n\n\nExample (library)\n-----------------\n\nInterpol can be integrated into Go applications:\n\n.. code-block:: go\n\n    package main\n\n    import (\n        \"fmt\"\n        \"log\"\n        \"github.com/avahidi/interpol\"\n    )\n\n    func main() {\n        rules := \"{{set data='Hello,Goodbye' sep=','}}, {{set data='World,friends' sep=','}}!\"\n\n        ip := interpol.New()\n        output, err := ip.Add(rules)\n        if err != nil {\n            log.Fatalf(\"Failed to create interpolator: %v\", err)\n        }\n\n        for ip.Next() {\n            fmt.Println(output.String())\n        }\n    }\n\n\n\nThis will produce:\n\n.. code-block::\n\n    Hello, World!\n    Goodbye, World!\n    Hello, friends!\n    Goodbye, friends!\n\n\nThe library allows you to define you own operators. See the examples/ folder for more information.\n\n\n\nInstallation\n------------\n\nThis will install the `police` command-line utility to ~/go/bin :\n\n.. code-block:: bash\n\n    go install github.com/avahidi/interpol/cmd/police@latest\n\n\nDocumentation\n-------------\n\nInterpol follows rules defined as expressions embedded in a string. Evaluating expressions within strings is often called string interpolation, hence we have chosen to call each rule fragment an \"interpolation\" and the logic behind it an \"interpolator\".\n\nSyntax\n~~~~~~\n\nAn interpolation has the following syntax:\n\n.. code-block::\n\n    {{type parameter1=value1 parameter2=value2 ... }}\n\nFor example:\n\n.. code-block::\n\n    {{counter min=1 max=10 step=3}}\n\n\nInterpolators\n~~~~~~~~~~~~~\n\nThe following interpolators are currently available:\n\n.. code-block::\n\n    ┌──────────────┬──────────────────────────────────────────────────────┐                  \n    │ Interpolator │ Description                                          │                  \n    ├──────────────┼──────────────────────────────────────────────────────┤                  \n    │ counter      │ A sequence of numbers                                │\n    │ random       │ A set of random numbers within a given range.        │\n    │ file         │ Lines from a file.                                   │\n    │ set          │ A set of values in a set                             │\n    │ copy         │ Output of another interpolator                       │\n    └──────────────┴──────────────────────────────────────────────────────┘ \n  \nEach interpolator has a number of parameters, some of which are optional and some have default values:\n  \n  \n\n.. code-block::\n\n    ┌──────────────┬───────────────┬─────────────────────────────────────────────────┐                  \n    │ Interpolator │ Mandatory     │ Optional                                        │ \n    ├──────────────┼───────────────┼─────────────────────────────────────────────────┤                  \n    │ counter      │               │ min=0, max=10, step=1, format=\"%d               │\n    │ random       │               │ min=0, max=10, count=5, format=\"%d              │\n    │ file         │ filename      │ count=-1, mode=linear, optional=false           │\n    │ set          │ data          │ sep=\"\", count=-1, mode=linear, optional=false   │\n    │ copy         │ from          │                                                 │\n    └──────────────┴───────────────┴─────────────────────────────────────────────────┘ \n                                                                                                           \n                                                                                    \n\nNotes:\n\n- `format` uses the standard Go `fmt.Printf()` format string.\n- `optional=true` allows the interpolation to produce an empty output.\n\nCopying                                                                                                 \n~~~~~~~                                                                                                 \nInterpolators can be given a `name` attribute. This is required when using the `copy` interpolator to repeat the value of another interpolation.                                              \n                                                                                                        \n.. code-block::                                                                                         \n\n    \"{{counter name=mycounter}} {{copy from=mycounter}}\"\n\nThis will yield \"0 0\", \"1 1\", \"2 2\", and so on.                                                         \n\nModifiers\n~~~~~~~~~\n\nInterpolators can have an output `modifier` to transform the generated value.\n\nFor example:\n\n.. code-block:: bash\n\n    $ police '{{set data=\"YES,no,mayBE\" sep=\",\" modifier=capitalize}}'\n    Yes\n    No\n    Maybe\n\nThe following modifiers are available:\n\n.. code-block:: bash\n\n    ┌────────────┬──────────────────────────────────────────────────────────────────────────────┐                             \n    │ Modifier   │ Description                                                                  │                             \n    ├────────────┼──────────────────────────────────────────────────────────────────────────────┤                         \n    │ empty      │ Returns an empty string, ignoring the input.                                 │                             \n    │ len        │ Returns the length of the input in bytes.                                    │                             \n    │ bitflip    │ Randomly flips one bit in the byte representation of the input.              │                             \n    │ byteswap   │ Randomly swaps two bytes in the input.                                       │                             \n    │ reverse    │ Reverses the input string (UTF-8 aware).                                     │                             \n    │ trim       │ Removes leading and trailing whitespace.                                     │                             \n    │ base64     │ Base64-encodes the input.                                                    │                             \n    │ toupper    │ Converts the input to upper case.                                            │                             \n    │ tolower    │ Converts the input to lower case.                                            │                             \n    │ capitalize │ Capitalizes each word in the input.                                          │                             \n    │ 1337       │ Applies \"l33t speak\" character substitutions (e.g., `e` -\u003e `3`, `o` -\u003e `0`). │                             \n    └────────────┴──────────────────────────────────────────────────────────────────────────────┘      \n\nLicense\n-------\n\nThis library is licensed under the GNU GENERAL PUBLIC LICENSE, version 2 (GPLv2).\n\nSee the file LICENSE for more information.\n","funding_links":[],"categories":["Security","安全"],"sub_categories":["HTTP Clients","HTTP客户端"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favahidi%2Finterpol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favahidi%2Finterpol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favahidi%2Finterpol/lists"}