intentionet / netconan

netconan - a Network Configuration Anonymizer
Apache License 2.0
145 stars 12 forks source link

Preserve more line context #102

Closed sfraint closed 5 years ago

sfraint commented 5 years ago

Some files, like JSON files or some network configuration files may have important context in sensitive lines, which is lost during anonymization.

Consider the following JSON file:

"Text": "password FOOBAR",
"Text2": "cable shared-secret FOOBAR",
"OtherField": ...

Which is no longer proper JSON format after anonymizing passwords:

"Text": "password netconanRemoved0
! Sensitive line SCRUBBED by netconan
"OtherField": ...

or consider this Juniper config snippet:

system {
  root-authentication {
    password FOOBAR;
  }
}

Which loses its line-terminating ; after anonymizing passwords:

system {
  root-authentication {
    password netconanRemoved0
  }
}

In both of these cases, it would be helpful to preserve the trailing context, so the anonymized files will still be formatted like the original (e.g. so the anonymized JSON file can still be interpreted as a valid JSON file).