Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
32fd829f
Commit
32fd829f
authored
Jun 12, 2018
by
Micaël Bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use `.with_index` on Enumerator
parent
1ed0b801
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
lib/pseudonymizer/dumper.rb
lib/pseudonymizer/dumper.rb
+6
-3
No files found.
lib/pseudonymizer/dumper.rb
View file @
32fd829f
...
...
@@ -14,12 +14,15 @@ module Pseudonymizer
def
anonymize
(
results
)
columns
=
results
.
columns
# Assume they all have the same table
to_filter
=
@anon_fields
&
columns
secret
=
Rails
.
application
.
secrets
[
:secret_key_base
]
key
=
Rails
.
application
.
secrets
[
:secret_key_base
]
digest
=
OpenSSL
::
Digest
.
new
(
'sha256'
)
Enumerator
.
new
do
|
yielder
|
results
.
each
do
|
result
|
to_filter
.
each
do
|
field
|
result
[
field
]
=
OpenSSL
::
HMAC
.
hexdigest
(
'SHA256'
,
secret
,
result
[
field
])
unless
result
[
field
].
nil?
next
if
result
[
field
].
nil?
result
[
field
]
=
OpenSSL
::
HMAC
.
hexdigest
(
digest
,
key
,
result
[
field
])
end
yielder
<<
result
end
...
...
@@ -133,7 +136,7 @@ module Pseudonymizer
file_path
=
get_and_log_file_name
(
"csv"
,
title
)
CSV
.
open
(
file_path
,
'w'
)
do
|
csv
|
contents
.
each_
with_index
do
|
row
,
i
|
contents
.
with_index
do
|
row
,
i
|
csv
<<
row
.
keys
if
i
==
0
# header
csv
<<
row
.
values
csv
.
flush
if
i
%
PAGE_SIZE
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment