Skip to content

Commit

Permalink
Adapt Elastic error logs (no more flood) and prevent any number param…
Browse files Browse the repository at this point in the history
… in bcrypt hash
  • Loading branch information
richard-julien committed Sep 5, 2019
1 parent a115bb8 commit 49eed88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ export const getAttributes = (indexName, id) => {
return data.body._source;
})
.catch(e => {
logger.error(`[ELASTICSEARCH] getAttributes > error getting ${id}`, e);
if (e.meta.statusCode !== 404) {
// If another error than not found.
logger.error(`[ELASTICSEARCH] getAttributes > error getting ${id}`, e);
}
return null;
});
};
6 changes: 4 additions & 2 deletions opencti-platform/opencti-graphql/src/domain/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const addUser = async (
has email "${escapeString(newUser.email)}",
${
newUser.password
? `has password "${bcrypt.hashSync(newUser.password)}",`
? `has password "${bcrypt.hashSync(newUser.password.toString())}",`
: ''
}
has firstname "${escapeString(newUser.firstname)}",
Expand Down Expand Up @@ -332,7 +332,9 @@ export const meEditField = (user, userId, input) => {
throw new ForbiddenAccess();
}
const value =
key === 'password' ? [bcrypt.hashSync(head(input.value), 10)] : input.value;
key === 'password'
? [bcrypt.hashSync(head(input.value).toString(), 10)]
: input.value;
const finalInput = { key, value };
return updateAttribute(userId, finalInput).then(userToEdit => {
return notify(BUS_TOPICS.StixDomainEntity.EDIT_TOPIC, userToEdit, user);
Expand Down

0 comments on commit 49eed88

Please sign in to comment.