[CRIU] [PATCH 1/2] crit: Add anonymize option.
Harshavardhan Unnibhavi
hvubfoss at gmail.com
Sun Jun 30 10:53:48 MSK 2019
When reporting a bug, it may not be acceptable for the reporter to send
raw images, as they may contain sensitive data. Hence, we need to teach
crit to "anonymize" images for publication.
Resolve Issue #360.
Signed-off-by: Harshavardhan Unnibhavi <hvubfoss at gmail.com>
---
lib/py/cli.py | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/lib/py/cli.py b/lib/py/cli.py
index abaf0720..fdb24dbe 100755
--- a/lib/py/cli.py
+++ b/lib/py/cli.py
@@ -3,6 +3,7 @@ import argparse
import sys
import json
import os
+import glob
import pycriu
@@ -271,7 +272,24 @@ def explore_rss(opts):
print('%-24s%s' % (pstr, vstr))
+def anonymize(opts):
+ try:
+ os.makedirs(opts['out'])
+ except OSError as err:
+ if err.errno != os.errno.EEXIST:
+ raise
+
+ img_files = glob.glob(os.path.join(opts['in'], '*.img'))
+ for i in img_files:
+ inf_opts = {'in':i, 'out':os.path.join(opts['out'], os.path.basename(i))}
+
+ try:
+ img = pycriu.images.load(inf(inf_opts))
+ except pycriu.images.MagicException as exc:
+ print("Unknown magic %#x.\n"\
+ "Found a raw image" %exc.magic, file=sys.stderr)
+ print("Skipping over %s, continuing ..." %os.path.basename(i))
explorers = { 'ps': explore_ps, 'fds': explore_fds, 'mems': explore_mems, 'rss': explore_rss }
@@ -329,6 +347,15 @@ def main():
show_parser.add_argument('--nopl', help = 'do not show entry payload (if exists)', action = 'store_true')
show_parser.set_defaults(func=decode, pretty=True, out=None)
+ # Anonymize
+ anon_parser = subparsers.add_parser('anonymize',
+ help = "anonymize binary images to remove sensitive information")
+ anon_parser.add_argument('-i', '--in',
+ help = "path to directory containing images to be anonymized")
+ anon_parser.add_argument('-o', '--out',
+ help = "path to directory where the anonymized images are to be stored")
+ anon_parser.set_defaults(func=anonymize)
+
opts = vars(parser.parse_args())
if not opts:
--
2.17.1
More information about the CRIU
mailing list