Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
b77d2178
Commit
b77d2178
authored
Dec 16, 2015
by
Frédéric Buclin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 1232578: Don't save hashed passwords in audit_log
r/a=dkl
parent
8a4cfa90
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
DB.pm
Bugzilla/Install/DB.pm
+27
-0
Object.pm
Bugzilla/Object.pm
+19
-1
No files found.
Bugzilla/Install/DB.pm
View file @
b77d2178
...
...
@@ -729,6 +729,9 @@ sub update_table_definitions {
# 2014-11-10 dkl@mozilla.com - Bug 1093928
$dbh
->
bz_drop_column
(
'longdescs'
,
'is_markdown'
);
# 2015-12-16 LpSolit@gmail.com - Bug 1232578
_sanitize_audit_log_table
();
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
...
...
@@ -3914,6 +3917,30 @@ sub _update_alias {
$dbh
->
bz_drop_column
(
'bugs'
,
'alias'
);
}
sub
_sanitize_audit_log_table
{
my
$dbh
=
Bugzilla
->
dbh
;
# Replace hashed passwords by a generic comment.
my
$class
=
'Bugzilla::User'
;
my
$field
=
'cryptpassword'
;
my
$hashed_passwd
=
$dbh
->
selectcol_arrayref
(
'SELECT added FROM audit_log WHERE class = ? AND field = ?
AND '
.
$dbh
->
sql_not_ilike
(
'hashed_with_'
,
'added'
),
undef
,
(
$class
,
$field
));
if
(
@$hashed_passwd
)
{
say
"Sanitizing hashed passwords stored in the 'audit_log' table..."
;
my
$sth
=
$dbh
->
prepare
(
'UPDATE audit_log SET added = ?
WHERE class = ? AND field = ? AND added = ?'
);
foreach
my
$passwd
(
@$hashed_passwd
)
{
my
(
undef
,
$sanitized_passwd
)
=
Bugzilla::Object::
_sanitize_audit_log
(
$class
,
$field
,
[
undef
,
$passwd
]);
$sth
->
execute
(
$sanitized_passwd
,
$class
,
$field
,
$passwd
);
}
}
}
1
;
__END__
...
...
Bugzilla/Object.pm
View file @
b77d2178
...
...
@@ -599,11 +599,29 @@ sub audit_log {
foreach
my
$field
(
keys
%
$changes
)
{
# Skip private changes.
next
if
$field
=~
/^_/
;
my
(
$from
,
$to
)
=
@
{
$changes
->
{
$field
}
}
;
my
(
$from
,
$to
)
=
$self
->
_sanitize_audit_log
(
$field
,
$changes
->
{
$field
})
;
$sth
->
execute
(
$user_id
,
$class
,
$self
->
id
,
$field
,
$from
,
$to
);
}
}
sub
_sanitize_audit_log
{
my
(
$self
,
$field
,
$changes
)
=
@_
;
my
$class
=
ref
(
$self
)
||
$self
;
# Do not store hashed passwords. Only record the algorithm used to encode them.
if
(
$class
eq
'Bugzilla::User'
&&
$field
eq
'cryptpassword'
)
{
foreach
my
$passwd
(
@$changes
)
{
next
unless
$passwd
;
my
$algorithm
=
'unknown_algorithm'
;
if
(
$passwd
=~
/{([^}]+)}$/
)
{
$algorithm
=
$1
;
}
$passwd
=
"hashed_with_$algorithm"
;
}
}
return
@$changes
;
}
sub
flatten_to_hash
{
my
$self
=
shift
;
my
$class
=
blessed
(
$self
);
...
...
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