Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Password Hardening #5503

Merged
merged 6 commits into from
Aug 26, 2022

Conversation

davidpil2002
Copy link
Contributor

Description of PR

Summary:
Added Password Hardening Tests according to HLD Test Plan

Context: By enabling the new Password Hardening feature and configured policies, the user will be enforce to use "strong" passwords according to the policies configured.

The new tests cases will cover all the possible password policies with good and bad cases, including:

  • Perform show command
  • Perform config command
  • Verify default values of the feature
  • Enable/Disable the feature
  • Test all passw policies available:
    • Configure passw policy classes of every existing types
    • Configure passw policy min using different valid values
    • Configure passw policy age expiration using different valid values
    • Configure passw policy age warning using different valid values
    • Configure passw policy username-password-match
    • Configure passw policy history using different valid values
      Note
      After creating a new policy is necessary to set a new password for a user to verify that the policy matches the configured.
      The set configuration should be validated using the show command.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • [*] Test case(new/improvement)

Back port request

  • 201911
  • 202012

Approach

What is the motivation for this PR?

Add new tests cases for testing the feature Password Hardening.

How did you do it?

There are 10 test scenarios each one of them config different policies and test the case with good(strong) passwords and bad(weak) passwords expecting results according to the configuration and the flow.
The configuration is done by using sonic-cli, sending different "config" commands.
In addition, the test is testing that the configuration in PAM files in the system change according to the expected.
The expected files were saved in the directory "sample".

How did you verify/test it?

New tests cases passed

Any platform specific information?

N/A

Supported testbed topology if it's a new test case?

any

Documentation

Link of HLD including feature design and Test plan:
https://github.com/Azure/SONiC/blob/master/doc/passw_hardening/hld_password_hardening.md

@davidpil2002 davidpil2002 requested a review from a team as a code owner April 12, 2022 08:45
@lgtm-com
Copy link

lgtm-com bot commented Apr 12, 2022

This pull request introduces 1 alert when merging c0d0e5d into 91d23e7 - view on LGTM.com

new alerts:

  • 1 for Unused local variable

@davidpil2002
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liat-grozovik liat-grozovik changed the title Password Hardening Tests Add support for Password Hardening Apr 13, 2022
@liat-grozovik liat-grozovik requested a review from liuh-80 April 18, 2022 12:37
Test passw policies configured in Linux system (PAM)
Test passw 'enabled/disable' by disabled and enable the passw and creating users between with strong/weak passw
"""
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
Copy link
Contributor

Choose a reason for hiding this comment

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

Please ignore all UTs when this feature not existed on target image with this helper method:
from tests.common.helpers.assertions import pytest_require

or

from tests.common.utilities import skip_release

The reason of this is, UT in sonic-mgmt will be run during sonic-mgmt on all branch, so forexample, when build 202011 branch, these UT should be ignored because the feature doest not exist on that branch.

also because this feature can be config as not build to image, then when feature not build we also need ignore all UTs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(I used pytest.skip, because pytest_require raise some problems to me)

@lgtm-com
Copy link

lgtm-com bot commented May 1, 2022

This pull request introduces 1 alert when merging c8cab76ccd74f85deee9fc0b4faa39097d90a437 into 6d67c13 - view on LGTM.com

new alerts:

  • 1 for Unused local variable

@davidpil2002 davidpil2002 force-pushed the passw_hardening branch 2 times, most recently from f016452 to 66d3262 Compare May 1, 2022 12:04
@lgtm-com
Copy link

lgtm-com bot commented May 1, 2022

This pull request introduces 1 alert when merging 66d32629eea07be3b9788ebcc716aad7771517bc into 6d67c13 - view on LGTM.com

new alerts:

  • 1 for Unused local variable

@lgtm-com
Copy link

lgtm-com bot commented May 1, 2022

This pull request introduces 1 alert when merging f0c999f into 6d67c13 - view on LGTM.com

new alerts:

  • 1 for Unused local variable

@liat-grozovik
Copy link
Collaborator

@liuh-80 could you please review and signoff?
@davidpil2002 should we wait for the merge once the feature is merged?

@davidpil2002
Copy link
Contributor Author

@liuh-80 could you please review and signoff? @davidpil2002 should we wait for the merge once the feature is merged?

yes, first the feature from sonic-buildimage should be merged, then the sonic-mgmt code

@zhangyanzhao zhangyanzhao requested a review from qiluo-msft June 27, 2022 16:04
@liat-grozovik
Copy link
Collaborator

@roysr-nv please also review

@roy-sror
Copy link
Contributor

@roysr-nv please also review

it was reviewed by @AntonHryshchuk

@zhangyanzhao
Copy link
Contributor

@davidpil2002 can you please help to sign the EasyCLA to unblock the merge? Thanks @liat-grozovik

@qiluo-msft
Copy link
Contributor

/easycla

@qiluo-msft qiluo-msft merged commit beb9e12 into sonic-net:master Aug 26, 2022
@davidpil2002 davidpil2002 mentioned this pull request Oct 2, 2022
3 tasks
allen-xf pushed a commit to allen-xf/sonic-mgmt that referenced this pull request Oct 28, 2022
### Description of PR
Summary:
Added Password Hardening Tests according to HLD Test Plan

Context: By enabling the new Password Hardening feature and configured policies, the user will be enforce to use "strong" passwords according to the policies configured.

The new tests cases will cover all the possible password policies with good and bad cases, including:
* Perform show command
* Perform config command
* Verify default values of the feature
* Enable/Disable the feature
* Test all passw policies available:
  * Configure passw policy classes of every existing types
  * Configure passw policy  min using different valid values
  * Configure passw policy  age expiration using different valid values
  * Configure passw policy  age warning using different valid values
  * Configure passw policy  username-password-match
  * Configure passw policy  history using different valid values
Note
After creating a new policy is necessary to set a new password for a user to verify that the policy matches the configured.
The set configuration should be validated using the show command.
### Approach
#### What is the motivation for this PR?
Add new tests cases for testing the feature Password Hardening.

#### How did you do it?
There are 10 test scenarios each one of them config different policies and test the case with good(strong) passwords and bad(weak) passwords expecting results according to the configuration and the flow.
The configuration is done by using sonic-cli, sending different "config" commands.
In addition, the test is testing that the configuration in PAM files in the system change according to the expected.
The expected files were saved in the directory "sample".

#### How did you verify/test it?
New tests cases passed
#### Any platform specific information?
N/A
#### Supported testbed topology if it's a new test case?
any
### Documentation

Link of HLD including feature design and Test plan:
https://github.com/Azure/SONiC/blob/master/doc/passw_hardening/hld_password_hardening.md
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.

7 participants