Skip to content
New issue

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

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

Already on GitHub? # to your account

Add policy check for SharePoint 3.2 when using service principal and update SharePoint 4.2 rego for deprecation #1309

Merged
merged 15 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ function Export-SharePointProvider {
$UsedPnP = ConvertTo-Json $false
if ($PnPFlag) {
$SPOTenant = ConvertTo-Json @($Tracker.TryCommand("Get-PnPTenant"))
$SPOSite = ConvertTo-Json @($Tracker.TryCommand("Get-PnPTenantSite",@{"Identity"="$($SPOSiteIdentity)"; "Detailed"=$true}) | Select-Object -Property *)
$SPOSite = ConvertTo-Json @($Tracker.TryCommand("Get-PnPTenantSite",@{"Identity"="$($SPOSiteIdentity)";}) | Select-Object -Property *)
$Tracker.AddSuccessfulCommand("Get-SPOTenant")
$Tracker.AddSuccessfulCommand("Get-SPOSite")
$UsedPnP = ConvertTo-Json $true
}
else {
$SPOTenant = ConvertTo-Json @($Tracker.TryCommand("Get-SPOTenant"))
$SPOSite = ConvertTo-Json @($Tracker.TryCommand("Get-SPOSite", @{"Identity"="$($SPOSiteIdentity)"; "Detailed"=$true}) | Select-Object -Property *)
$SPOSite = ConvertTo-Json @($Tracker.TryCommand("Get-SPOSite", @{"Identity"="$($SPOSiteIdentity)";}) | Select-Object -Property *)
$Tracker.AddSuccessfulCommand("Get-PnPTenant")
$Tracker.AddSuccessfulCommand("Get-PnPTenantSite")
}
Expand Down
86 changes: 40 additions & 46 deletions PowerShell/ScubaGear/Rego/SharepointConfig.rego
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,19 @@ Tenant := input.SPO_tenant[0] if {

SharingCapability := Tenant.SharingCapability

SharingString := concat("", [
"External Sharing is set to ",
SliderSettings(SharingCapability),
"."
])
NAString(SharingSetting, Negation) := concat("", [
"This policy is only applicable if the external sharing slider on the admin page is set to ",
SharingSetting,
". ",
"See %v for more info"
]) if Negation == false
else := concat("", [
"This policy is only applicable if the external sharing slider on the admin page is not set to ",
SharingSetting,
". ",
"See %v for more info"
]) if Negation == true

NAString(SharingSetting) := concat("", [
"This policy is only applicable if External Sharing is set to any value other than ",
SharingSetting,
". ",
"See %v for more info"
])


###################
Expand Down Expand Up @@ -160,7 +161,7 @@ tests contains {
} if {
SharingCapability == ONLYPEOPLEINORG
PolicyId := "MS.SHAREPOINT.1.3v1"
Reason := NAString(SliderSettings(0))
Reason := NAString(SliderSettings(0), true)
}
#--

Expand Down Expand Up @@ -237,9 +238,7 @@ tests contains {

ErrStr := concat(" ", [
"Requirement not met:",
"External Sharing is set to",
SliderSettings(SharingCapability),
"and expiration date is not set to 30 days or less."
"total expiration days are not set to 30 days or less"
])

# Standard test to compare against baseline
Expand All @@ -256,7 +255,11 @@ tests contains {
"RequirementMet": Status
} if {
SharingCapability == ANYONE
Status := Tenant.RequireAnonymousLinksExpireInDays <= 30
Conditions := [
Tenant.RequireAnonymousLinksExpireInDays >= 1,
Tenant.RequireAnonymousLinksExpireInDays <= 30
]
Status := count(FilterArray(Conditions, true)) == 2
}

# Test for N/A case
Expand All @@ -270,7 +273,7 @@ tests contains {
} if {
PolicyId := "MS.SHAREPOINT.3.1v1"
SharingCapability != ANYONE
Reason := NAString(SliderSettings(2))
Reason := NAString(SliderSettings(2), false)
}
#--

Expand Down Expand Up @@ -300,7 +303,7 @@ FileAndFolderLinkPermission(2, 1) := concat(": ", [
])

# This policy is only applicable if external sharing is set to "Anyone"
# Both link types must be 1 & OneDrive_PnP_Flag must be false for policy to pass
# Both link types must be 1 for policy to pass
tests contains {
"PolicyId": "MS.SHAREPOINT.3.2v1",
"Criticality": "Shall",
Expand All @@ -309,7 +312,6 @@ tests contains {
"ReportDetails": FileAndFolderLinkPermission(FileLinkType, FolderLinkType),
"RequirementMet": Status
} if {
input.OneDrive_PnP_Flag == false
SharingCapability == ANYONE

FileLinkType := Tenant.FileAnonymousLinkType
Expand All @@ -331,24 +333,12 @@ tests contains {
"RequirementMet": false
} if {
PolicyId := "MS.SHAREPOINT.3.2v1"
input.OneDrive_PnP_Flag == false
SharingCapability != ANYONE
Reason := NAString(SliderSettings(2))
}

tests contains {
"PolicyId": PolicyId,
"Criticality": "Shall/Not-Implemented",
"Commandlet": [],
"ActualValue": [],
"ReportDetails": NotCheckedDetails(PolicyId),
"RequirementMet": false
} if {
PolicyId := "MS.SHAREPOINT.3.2v1"
input.OneDrive_PnP_Flag == true
Reason := NAString(SliderSettings(2), false)
}
#--


#
# MS.SHAREPOINT.3.3v1
#--
Expand Down Expand Up @@ -405,10 +395,14 @@ tests contains {
} if {
PolicyId := "MS.SHAREPOINT.3.3v1"
not SharingCapability in [ANYONE, NEWANDEXISTINGGUESTS]
Reason := concat(" ", [
SharingString,
NAString(concat(" ", [SliderSettings(0), "or", SliderSettings(3)]))
])
Reason := NAString(
concat(" ", [
SliderSettings(2),
"or",
SliderSettings(1)
]),
false
)
}
#--

Expand All @@ -420,17 +414,17 @@ tests contains {
# MS.SHAREPOINT.4.2v1
#--

# 1 == Allow users to run custom script on self-service created sites
# 2 == Prevent users from running custom script on self-service created sites
# Microsoft has planned to remove the custom scripting configuration option
# from SharePoint and OneDrive. We are setting this policy to not-implemented
# and will likely remove it from the baseline in the next version.
tests contains {
"PolicyId": "MS.SHAREPOINT.4.2v1",
"Criticality": "Shall",
"PolicyId": PolicyId,
"Criticality": "Shall/Not-Implemented",
"Commandlet": ["Get-SPOSite", "Get-PnPTenantSite"],
"ActualValue": [SitePolicy.DenyAddAndCustomizePages],
"ReportDetails": ReportDetailsBoolean(Status),
"RequirementMet": Status
"ActualValue": [],
"ReportDetails": NotCheckedDeprecation,
"RequirementMet": false
} if {
some SitePolicy in input.SPO_site
Status := SitePolicy.DenyAddAndCustomizePages == 2
PolicyId := "MS.SHAREPOINT.4.2v1"
}
#--
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@ SPOTenant := {
"FolderAnonymousLinkType": 1,
"EmailAttestationRequired": true,
"EmailAttestationReAuthDays": 30
}

SPOSite := {
"DenyAddAndCustomizePages": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ test_SharingDomainRestrictionMode_SharingCapability_OnlyPeopleInOrg_NotApplicabl
Output := sharepoint.tests with input.SPO_tenant as [SPOTenant]

ReportDetailsString := concat(" ", [
"This policy is only applicable if External Sharing",
"is set to any value other than Only People In Your Organization.",
"This policy is only applicable if the external sharing slider",
"on the admin page is not set to Only People In Your Organization.",
"See %v for more info"
])
TestResult(PolicyId, Output, CheckedSkippedDetails(PolicyId, ReportDetailsString), false) == true
Expand Down
Loading
Loading