Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Validate the hash salt during object creation#237

Merged
Craigacp merged 2 commits intooracle:mainfrom
geoffreydstewart:hasher-validate-salt
May 12, 2022
Merged

Validate the hash salt during object creation#237
Craigacp merged 2 commits intooracle:mainfrom
geoffreydstewart:hasher-validate-salt

Conversation

@geoffreydstewart
Copy link
Member

Description

These changes add validations of the hash salt during object creation, either programmatically or via the Configuration System.

Motivation

These changes fix #233

Copy link
Member

@Craigacp Craigacp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small formatting things mostly. The tests look good, thanks for adding them.

* Used by the OLCUT configuration system, and should not be called by external code.
*/
@Override
public synchronized void postConfig() throws PropertyException{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These postConfigs don't access any other resources under synchronization elsewhere in the class, so we don't need to make them synchronized to avoid static analysis false positives.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it makes sense to only apply synchronization as needed to safely modify an attribute. I think I may have misunderstood that from a previous discussion. Thanks for clarifying.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the false positive only arises in Trainers as those also access the RNG field under synchronization. In practice as postConfig is always only called either from the constructor, or from OLCUT before the object is published it doesn't actually need synchronization, but the static analysis tools just see a public method and so warn on it.

Copy link
Member

@Craigacp Craigacp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@Craigacp Craigacp merged commit 888a9bb into oracle:main May 12, 2022
@geoffreydstewart geoffreydstewart deleted the hasher-validate-salt branch May 12, 2022 21:38
Craigacp pushed a commit that referenced this pull request Oct 25, 2022
* Validate the hash salt during object creation

* Changes to address code review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hasher.validateSalt(salt) is underutilized

2 participants