Skip to content

Add a CLI script for scrubbing email addresses etc from export files#69

Open
tellyworth wants to merge 1 commit intotrunkfrom
add/wxr-scrub
Open

Add a CLI script for scrubbing email addresses etc from export files#69
tellyworth wants to merge 1 commit intotrunkfrom
add/wxr-scrub

Conversation

@tellyworth
Copy link
Copy Markdown
Contributor

We could periodically use this on the server side to generate sample export files.

I used DomDocument rather than regexes to better deal with large files and unexpected whitespace etc.

@tellyworth tellyworth requested review from dd32 and iandunn June 3, 2022 01:50
@tellyworth
Copy link
Copy Markdown
Contributor Author

@iandunn mentioned the idea of taking an allowlist approach to scrubbing, rather than scrubbing selected elements like I've done here. That's a good idea for future, especially if we were to reuse this for other sites. That was my other reason for using DomDocument - we could traverse every node and scrub everything that's not explicitly allowed.

If you think this is ok as a starting point let's merge it and add some handbook imports.

Comment thread env/scrub-export.php

fwrite( $fp_out, $doc->saveXML() );

fclose( $fp_out ); No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fclose( $fp_out );
fclose( $fp_out );
readline( "\nMake sure you manually review the diff before committing this to the repository! This script might have missed some PII. \n" );

@iandunn
Copy link
Copy Markdown
Member

iandunn commented Jun 3, 2022

Here's an example of a safelist approach, for future reference:

https://github.com/iandunn/regolith/blob/824b999c11fae10c4777b8f517df63c6e6fd0a0d/bin/sync-production-content.sh#L91-L164

It works on a SQL dump rather than WRX, but has safelists of various data that might be useful.

@tellyworth
Copy link
Copy Markdown
Contributor Author

This is probably not needed now but worth keeping for future use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants