{"id":34209489,"url":"https://github.com/kristinjeanna/redact","last_synced_at":"2026-03-09T23:36:42.353Z","repository":{"id":40784048,"uuid":"506802890","full_name":"kristinjeanna/redact","owner":"kristinjeanna","description":"A string redaction/sanitization package for Golang that provides a variety of string redaction mechanisms.","archived":false,"fork":false,"pushed_at":"2023-01-05T19:07:19.000Z","size":83,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T13:03:51.273Z","etag":null,"topics":["go","golang","redact","redaction","redactions","sanitization","sanitize","sanitizer","string","strings"],"latest_commit_sha":null,"homepage":"","language":"Go","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/kristinjeanna.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}},"created_at":"2022-06-23T21:57:20.000Z","updated_at":"2022-06-27T16:26:09.000Z","dependencies_parsed_at":"2023-02-04T11:31:53.110Z","dependency_job_id":null,"html_url":"https://github.com/kristinjeanna/redact","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kristinjeanna/redact","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristinjeanna%2Fredact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristinjeanna%2Fredact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristinjeanna%2Fredact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristinjeanna%2Fredact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kristinjeanna","download_url":"https://codeload.github.com/kristinjeanna/redact/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristinjeanna%2Fredact/sbom","scorecard":{"id":570349,"data":{"date":"2025-08-11","repo":{"name":"github.com/kristinjeanna/redact","commit":"2d02aa80aee610a75af6134090e256898fab23fb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/21 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28","Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29","Warn: no topLevel permission defined: .github/workflows/build.yml:1","Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/kristinjeanna/redact/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/kristinjeanna/redact/build.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/kristinjeanna/redact/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/kristinjeanna/redact/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/kristinjeanna/redact/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/kristinjeanna/redact/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:72: update your workflow using https://app.stepsecurity.io/secureworkflow/kristinjeanna/redact/codeql-analysis.yml/main?enable=pin","Warn: goCommand not pinned by hash: .github/workflows/build.yml:29","Warn: goCommand not pinned by hash: .github/workflows/build.yml:30","Warn: goCommand not pinned by hash: .github/workflows/build.yml:31","Warn: goCommand not pinned by hash: .github/workflows/build.yml:32","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   4 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":7,"reason":"SAST tool detected but not run on all commits","details":["Info: SAST configuration detected: CodeQL","Warn: 0 commits out of 9 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T16:10:49.256Z","repository_id":40784048,"created_at":"2025-08-20T16:10:49.256Z","updated_at":"2025-08-20T16:10:49.256Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30316772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["go","golang","redact","redaction","redactions","sanitization","sanitize","sanitizer","string","strings"],"created_at":"2025-12-15T20:43:38.159Z","updated_at":"2026-03-09T23:36:42.337Z","avatar_url":"https://github.com/kristinjeanna.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# github.com/kristinjeanna/redact\n\n[![GitHub license](https://img.shields.io/github/license/kristinjeanna/redact.svg?style=flat\u0026label=License)](https://github.com/kristinjeanna/redact/blob/main/LICENSE) ![Last commit](https://img.shields.io/github/last-commit/kristinjeanna/redact?style=flat\u0026label=Last%20commit) ![Build and test](https://github.com/kristinjeanna/redact/actions/workflows/build.yml/badge.svg?branch=main) ![Latest tag](https://img.shields.io/github/v/tag/kristinjeanna/redact?label=Latest%20tag) [![Go Report Card](https://goreportcard.com/badge/github.com/kristinjeanna/redact)](https://goreportcard.com/report/github.com/kristinjeanna/redact) [![codecov](https://codecov.io/gh/kristinjeanna/redact/branch/main/graph/badge.svg?token=mHRY7hXtrB)](https://codecov.io/gh/kristinjeanna/redact) [![Go Reference](https://pkg.go.dev/badge/github.com/kristinjeanna/redact.svg)](https://pkg.go.dev/github.com/kristinjeanna/redact)\n\nPackage `redact` provides a variety of string redactor implementations. The available redactors include: `simple`, `substring`, `blackout`, `middle`, `regex`, `url`, and `chain`.\n\n\u003cdetails open=\"open\"\u003e\n\u003csummary\u003eTable of Contents\u003c/summary\u003e\n\n- [Install](#install)\n- [Overview of redactors](#overview-of-redactors)\n  - [`simple`](#simple)\n  - [`substring`](#substring)\n  - [`blackout`](#blackout)\n  - [`middle`](#middle)\n  - [`regex`](#regex)\n  - [`url`](#url)\n  - [`chain`](#chain)\n\n\u003c/details\u003e\n\n## Install\n\n```shell\ngo get -u github.com/kristinjeanna/redact\n```\n\n## Overview of redactors\n\nEach redactor implements the `redact.Redactor` interface:\n\n```go\n// Redactor is the common interface implemented by all redactors.\ntype Redactor interface {\n\n    // Redact redacts the input string and returns the result.\n    Redact(s string) (string, error)\n}\n```\n\n### `simple`\n\nThe `simple` redactor is a redactor that simply replaces an entire\nstring with a specified replacement string.\n\n``` go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    \"github.com/kristinjeanna/redact/simple\"\n)\n\nfunc main() {\n    redactor := simple.New(\"[redacted]\")\n    input := \"this string contains sensitive information\"\n\n    result, err := redactor.Redact(input)\n    if err != nil {\n        log.Fatalf(\"an error occurred while redacting: %s\", err)\n    }\n\n    fmt.Println(result)\n    // Output: [redacted]\n}\n```\n\n### `substring`\n\nThe `substring` redactor is a redactor that replaces all occurrences of the\nsubstring in the specified string.\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    \"github.com/kristinjeanna/redact/substring\"\n)\n\nfunc main() {\n    redactor := substring.New(\"contains sensitive\", \"XXXXX\")\n    input := \"this string contains sensitive information\"\n\n    result, err := redactor.Redact(input)\n    if err != nil {\n        log.Fatalf(\"an error occurred while redacting: %s\", err)\n    }\n\n    fmt.Println(result)\n    // Output: this string XXXXX information\n}\n\n```\n\n### `blackout`\n\nThe `blackout` redactor strikes out each non-whitespace character of an input\nstring with a specified replacement string.\n\nThe following example uses a single Unicode full block character (U+2588) to\nredact the input string:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    \"github.com/kristinjeanna/redact/blackout\"\n)\n\nfunc main() {\n    redactor := blackout.New(\"█\")\n    input := \"this string contains sensitive information\"\n\n    result, err := redactor.Redact(input)\n    if err != nil {\n        log.Fatalf(\"an error occurred while redacting: %s\", err)\n    }\n\n    fmt.Println(result)\n    // Output: ████ ██████ ████████ █████████ ███████████\n}\n```\n\n### `middle`\n\nThe `middle` redactor is a redactor that replaces the middle contents of a string with a replacement string, leaving a prefix of unredacted characters and a suffix of unredacted characters if the input string is long enough. For shorter input strings, the redactor uses only a prefix or suffix or just the replacement string itself.\n\nThe following example redacts the middle portion of the string:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    \"github.com/kristinjeanna/redact/middle\"\n)\n\nfunc main() {\n    redactor := middle.New()\n    input := \"this string contains sensitive information\"\n\n    result, err := redactor.Redact(input)\n    if err != nil {\n        log.Fatalf(\"an error occurred while redacting: %s\", err)\n    }\n\n    fmt.Println(result)\n    // Output: thi[redacted]ion\n}\n```\n\nThe prefix and suffix default to 3 characters but this is configurable when\ncreating a redactor via the `middle.NewFromOptions` function. Additionally,\na mode option can enable only the prefix or suffix of the input string to\nremain unredacted.\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    m \"github.com/kristinjeanna/redact/middle\"\n)\n\nfunc main() {\n    redactor, err := m.NewFromOptions(\n        m.WithMode(PrefixOnlyMode),\n        m.WithReplacementText(\"XXXXX\"),\n        m.WithPrefixLength(8),\n    )\n    if err != nil {\n        log.Fatalf(\"an error occurred while creating redactor: %s\", err)\n    }\n    input := \"this string contains sensitive information\"\n\n    result, err := redactor.Redact(input)\n    if err != nil {\n        log.Fatalf(\"an error occurred while redacting: %s\", err)\n    }\n\n    fmt.Println(result)\n    // Output: this strXXXXX\n}\n```\n\n### `regex`\n\nThe `regex` reactor is a redactor that performs redaction according to a slice of\nredactor/regex pairs. For each match of a regex, the corresponding redactor is\nexecuted on that match.\n\nNew pairs can be created via the `NewPair()` and the\n`NewPairUsingSimple()` functions. `NewPairUsingSimple()` is a convenience\nmethod to create a pair using a `SimpleRedactor` which associates a regex\nwith a replacement string. This function is also the means by which regular\nexpression capture groups can be used since the\n`(*regexp.Regexp).ReplaceAllString()` is employed by the `Redact()` function\nfor pairs having a `SimpleRedactor`. When a pair possesses a redactor other\nthan `SimpleRedactor`, the `Redact()` function invokes the redactor on\nsuccessively modified versions of the input string. Capture group may not\nalways work, especially in the cases where the replacement text matches against\nthe regex. The `Redact()` method will return an error in such cases to prevent\nan infinite loop.\n\nThe following example redacts the letters \"i\" and \"s\" from the input string:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    \"github.com/kristinjeanna/redact/regex\"\n)\n\nfunc main() {\n    // a regex.Pair holds the regex and the replacement string for matches\n    pair, err := regex.NewPairUsingSimple(\"X\", \"[is]\")\n    if err != nil {\n        log.Fatalf(\"an error occurred while create regex replacement pair: %s\", err)\n    }\n\n    redactor, err := regex.New([]Pair{*pair})\n    if err != nil {\n        log.Fatalf(\"an error occurred while creating redactor: %s\", err)\n    }\n    input = \"this string contains sensitive information\"\n\n    result, err := redactor.Redact(input)\n    if err != nil {\n        log.Fatalf(\"an error occurred while redacting: %s\", err)\n    }\n\n    fmt.Println(result)\n    // Output: thXX XtrXng contaXnX XenXXtXve XnformatXon\n}\n```\n\nThe following shows an example of using capture groups:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    \"github.com/kristinjeanna/redact/regex\"\n)\n\nfunc main() {\n    // a regex.Pair holds the regex and the replacement redactor for matches\n    pair, err := NewPairUsingSimple(\"${1}XXXX\", \"(b[aA][rRzZ])\")\n    if err != nil {\n        log.Fatalf(\"an error occurred while creating the regex pair: %s\", err)\n    }\n\n    // the redactor is constructed with a slice of Pairs\n    redactor, err := New([]Pair{*pair})\n    if err != nil {\n        log.Fatalf(\"an error occurred while creating redactor: %s\", err)\n    }\n\n    sampleString := \"foo bar baz\"\n    result, err := redactor.Redact(sampleString)\n    if err != nil {\n        log.Fatalf(\"an error occurred while redacting: %s\", err)\n    }\n\n    fmt.Println(result)\n    // Output: foo barXXXX bazXXXX\n}\n```\n\n### `url`\n\nThe `url` redactor enables redacting a password and, optionally a\nusername, from a URL string.\n\nThe following example redacts the password from a MySQL connection string:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    \"github.com/kristinjeanna/redact/url\"\n)\n\nfunc main() {\n    redactor := url.New(\"REDACTED\", nil)\n    input := \"mysql://user:password@localhost:3306\"\n\n    result, err := redactor.Redact(input)\n    if err != nil {\n        log.Fatalf(\"an error occurred while redacting: %s\", err)\n    }\n\n    fmt.Println(result)\n    // Output: mysql://user:REDACTED@localhost:3306\n}\n\n```\n\n### `chain`\n\nThe `chain` redactor consists of a slice of redactors that each redact an\ninput string in the order that they appear in the slice.\n\nThe following example chains a [`substring`](#substring) redactor with a\n[`regex`](#regex) redactor:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    \"github.com/kristinjeanna/redact\"\n    \"github.com/kristinjeanna/redact/chain\"\n    \"github.com/kristinjeanna/redact/regex\"\n    \"github.com/kristinjeanna/redact/substring\"\n)\n\nfunc main() {\n    substringRedactor := substring.New(\"contains\", \"HIDES\")\n\n    regexPair, err := regex.NewPairUsingSimple(\" [redacted] \", `(?i)\\ss\\w*\\s`)\n    if err != nil {\n        log.Fatalf(\"an error occurred while creating regex pair: %s\", err)\n    }\n    regexRedactor, err := regex.New([]regex.Pair{*regexPair})\n    if err != nil {\n        log.Fatalf(\"an error occurred while creating regex redactor: %s\", err)\n    }\n\n    chainRedactor := chain.New([]redact.Redactor{substringRedactor, regexRedactor})\n    input := \"this string contains sensitive information\"\n\n    result, err := chainRedactor.Redact(input)\n    if err != nil {\n        log.Fatalf(\"an error occurred while redacting: %s\", err)\n    }\n\n    fmt.Println(result)\n    // Output: this [redacted] HIDES [redacted] information\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristinjeanna%2Fredact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkristinjeanna%2Fredact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristinjeanna%2Fredact/lists"}