[CRIU] [PATCH 3/3] Issue #360: Anonymize image files
Pavel Emelianov
xemul at virtuozzo.com
Tue Jun 25 16:19:09 MSK 2019
On 6/25/19 2:49 PM, Harshavardhan Unnibhavi wrote:
> On Mon, Jun 24, 2019 at 5:30 PM Pavel Emelianov <xemul at virtuozzo.com> wrote:
When responding on patch comments, please, keep the criu at openvz.org in Cc.
My answers are inline.
>>> + anon_dict = strip.anon_handler(img, m)
>>> + if anon_dict != -1:
>>> + pycriu.images.dump(anon_dict, outf(temp))
>>
>> A message about skipping the file is needed.
> What extra message should I include? I just borrowed the print
> statement string from the decode function.
Something that prints on the screen that a particular image file has been skipped
from anonymization.
>>> +def files_anon(image):
>>> + levels = {}
>>> +
>>> + for e in image['entries']:
>>> + f_path = e['reg']['name']
>>> + f_path = f_path.split('/')
>>> +
>>> + lev_num = 0
>>> + for p in f_path:
>>> + if p == '':
>>> + continue
>>> + if lev_num in levels.keys():
>>> + if p not in levels[lev_num].keys():
>>> + temp = list(p)
>>> + random.shuffle(temp)
>>
>> Erm, I'm not 100% it's OK to anonymize file paths like that.
> Yeah, so basically it transforms /bin/lib to something like
> "nbi/bli/". How would you want me to change it?
Radostin suggested to calculate some checksum on the path component and I agree with him.
>>> + levels[lev_num][p] = ''.join(temp)
>>> + else:
>>> + levels[lev_num] = {}
>>> + temp = list(p)
>>> + random.shuffle(temp)
>>> + levels[lev_num][p] = ''.join(temp)
>>
>> Can we factor out these two branches a bit? Smth like
>>
>> if lev_num not in levels.keys():
>> levels[lev_num] = {}
>> if p not in levels[lev_num].keys():
>> temp = list(p)
>> random.shuffle(temp)
>> levels[lev_num][p] = ''.join(temp)
>>
> Sure I will change it.
Thanks!
-- Pavel
More information about the CRIU
mailing list