Skip to content

Commit

Permalink
bump: hash algo to sha512
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasHeine committed Oct 1, 2024
1 parent e1ce9f3 commit 53d0a58
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const getUser = (username: String, users: User[]): User | null => {
export const isValidUserAsync = (username: string, password: string, callback:(err: Error | null, isAuthorized?: boolean) => void) => {
const user = getUser(username, userList);
if (user) {
const hash = createHash("md5").update(password).digest("hex")
const hash = createHash("sha512").update(password).digest("hex")

Check failure

Code scanning / CodeQL

Use of password hash with insufficient computational effort High

Password from
an access to password
is hashed insecurely.
if (hash === user.password) {
green(` User:'${user.username}' logged in as '${user.roles}'! `);
callback(null, true);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/userfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class UserFile {
this.userList.push(Object.freeze({
username: user.username,
roles: user.roles,
password: createHash("md5").update(user.password).digest("hex")
password: createHash("sha512").update(user.password).digest("hex")

Check failure

Code scanning / CodeQL

Use of password hash with insufficient computational effort High

Password from
an access to password
is hashed insecurely.
}))
}

Expand Down
6 changes: 3 additions & 3 deletions user.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"users": [
{
"username":"admin",
"password":"6e6fdf956d04289354dcf1619e28fe77",
"password":"74e65264f45665748b385eb67d7531f285cee07d729e0ca18151d2e97be1837d5974b2a3747ad3db3310f0f98cec7fa622620ebd84e28cdc9fa3cc4e91be1b14",
"roles":"Supervisor;ConfigureAdmin;SecurityAdmin"
},
{
"username":"operator",
"password":"6d5779b9b85bd4f11e44c9772e0de602",
"password":"038e0f02c2776458dfe506724b62bd91c35e82ee8aa2bfddc7b19bb9acc7915abad0593c78c7831f97a0d7b5a0315fea2235f27e7fbf438bd86416dde12adae7",
"roles":"Operator;ConfigureAdmin"
},
{
"username":"guest",
"password":"de1774aac52706b13a39a08ad3ca7dfe",
"password":"9e98a8d3ed61072c8da7b61c487d95d7612698d2259374d594e74444692c9f4e0f01e742745af8b4c80d61a7f182255e9cdb4d07f76c619e1fd7e1c49bac05ac",
"roles":"AuthenticatedUser"
}
]
Expand Down

0 comments on commit 53d0a58

Please sign in to comment.