Skip to content

Add GraphQL mutation `projectTextReplace`

Joe Woodward requested to merge feat/450701-redact-text into master

What does this MR do and why?

Add GraphQL mutation projectTextReplace

Allows maintainers+ to replace text via the GraphQL API.

Takes 2 arguments:

  • projectPath - full path of the project to redact
  • replacements - list of replacements

Valid replacements values are documented here https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#_content_based_filtering

Returns nothing when successful Returns errors when something went wrong

Part of https://gitlab.com/gitlab-org/gitlab/-/issues/450701

Changelog: added

How to set up and validate locally

Install git-filter-repo locally (not bundled with GDK yet)

brew install git-filter-repo

Run mutation

See the linked docs for information on how to replace text with different options. Look for a file in the repo you will redact and then use the options to redact in various ways. By default the replacement will be ***REMOVED***, however, you can also specify what to replace with e.g. foo==>bar will replace all instances of foo with bar

mutation {
  # projectTextRedact(input: { projectPath: "Flightjs/flight", replacements: ["flight"]}) {
  projectTextReplace(input: { projectPath: "Flightjs/flight", replacements: ["flight"]}) {
    errors
  }
}

Config options:

p455w0rd
foo==>bar
literal:MM/DD/YYYY==>YYYY-MM-DD

NOTE: We do not support regex: or glob: replacements due to potential for ReDoS attacks.

More details can be seen in the 'Content based filtering' section of the man page

https://gitlab.com/gitlab-org/gitlab/-/issues/450701#note_1899302451

Edited by Joe Woodward

Merge request reports