-
Notifications
You must be signed in to change notification settings - Fork 225
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 policy check for SharePoint 3.2 when using service principal and update SharePoint 4.2 rego for deprecation #1309
Conversation
It is not clear why the test_File_Folder_AnonymousLinkType_Correct should produce a Pass? The SharingCapability is explicitly set to 2 (Anyone) within the unit test, but the other fields that are checked by the policy FileAnonymousLinkType & FolderAnonymousLinkType are not set in the unit test. Since they are already setup to the compliant value of 1 in the SharepointBaseConfig.rego file, the policy passes, but as a developer when I read the unit test this is not clear and I think this will make it hard to maintain these tests and know what they doing. I am wondering if we should explicitly set the values related to the policy and scenario we are testing within each unit test? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the code updates, unit tests and functional tests. Will leverage the support of another team member to perform hands-on testing.
I had a couple of minor questions related to the consistency and maintainability of the unit tests. Other than that, looks good. Nice work.
@tkol2022 Thanks for the review. I addressed your feedback in 7bc0975 |
7bc0975
to
b459215
Compare
PowerShell/ScubaGear/Testing/Unit/Rego/Sharepoint/SharepointConfig_03_test.rego
Show resolved
Hide resolved
PowerShell/ScubaGear/Testing/Unit/Rego/Sharepoint/SharepointConfig_03_test.rego
Show resolved
Hide resolved
PowerShell/ScubaGear/Testing/Unit/Rego/Sharepoint/SharepointConfig_03_test.rego
Show resolved
Hide resolved
PowerShell/ScubaGear/Testing/Unit/Rego/Sharepoint/SharepointConfig_03_test.rego
Show resolved
Hide resolved
@mitchelbaker-cisa Seems there is a logic flaw in the Rego implementation for policy 3.1 that I found when testing the branch. It is easy to fix so I recommend that you address it now especially given the importance of this release. To recreate the problemSet the external sharing slider to Anyone Uncheck the expiration days option Run ScubaGear and observe that it produces a Pass which is incorrect because the expiration option was not selected and configured The fixI believe the fix is relatively straightforward. When the expiration checkbox is unselected in the portal, you will notice that the JSON produces a value of -1 for RequireAnonymousLinksExpireInDays, so I am thinking that we need to ensure that the value of the field is between 1 and 30 inclusive. Currently the Rego code only checks for <= 30 and hence why it is flawed. Take a look and see if you agree. |
I tested interactive and non-interactive against E5 tenant and policy 3.2 seems to behave as expected. |
I addressed the logic for policy 3.1 to account for the negative integer value, -1, when the Anyone links checkbox is not set. The policy now displays a fail for this case. The report details for policies 3.1-3.3 are also fixed. |
@Sloane4 Can you test the negative integer value logic and make sure it works for you? would be nice to have some independent validation. |
6bd347d
to
32bd22a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont forget to rebase with main
8f181fb
to
b280935
Compare
…h service principal
…ce principal tests
…cked), added to both unit/functional tests
b280935
to
c21eee2
Compare
Final TestsI did a final functional test on all the Sharepoint policies that were affected by this PR 1.3, 3.1, 3.2, 3.3, 4.2 @nanda-katikaneni Ready for merge |
🗣 Description
Removed
input.OneDrive_PnP_Flag == false/true
statements and Not-Implemented test inSharePointConfig.rego
. Theinput.OneDrive_PnP_Flag
is still used in the SharePoint unit tests to indicate spo/pnp variantsRemoved unnecessary fields from
sharepoint.spo.testplan.yaml
to get rid of warnings; removed deprecated parameter ("Detailed"=$true) from Get-SPOSite and Get-PnPTenantSite in SharePoint providerExpanded unit test coverage for SharePoint 3.2 to cover service principal cases in
SharepointConfig_03_test.rego
; expanded functional test coverage for SharePoint 3.2 in thesharepoint.pnp.testplan.yaml
Logic for SharePoint 3.1 fixed to account for negative integer value, -1, when the Anyone links checkbox is not set. The policy now displays a fail for this case
Set SharePoint 4.2 to not-implemented in
SharepoingConfig.rego
, updated its unit/functional tests💭 Motivation and context
Closes #1221
Closes #1268
Closes #1220
Closes #1324
closes #622
🧪 Testing
Checkout the branch locally:
Check if all unit tests pass:
Check if all functional tests pass against SharePoint, use both spo/pnp variants.
✅ Pre-approval checklist
✅ Pre-merge checklist
PR passed smoke test check.
Feature branch has been rebased against changes from parent branch, as needed
Use
Rebase branch
button below or use this reference to rebase from the command line.Resolved all merge conflicts on branch
Notified merge coordinator that PR is ready for merge via comment mention
✅ Post-merge checklist