Skip to content
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
1 change: 1 addition & 0 deletions spfx/src/webparts/siteAdmin/SiteAdminWebPart.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"DisableSensitivityLabelOverride": false,
"MaxStorage": 25,
"MaxStorageDescription": "The max threshold has been met.",
"ReportsDLPFileExt": "csv doc docx dot dotx pdf pot potx pps ppsx ppt pptx txt xls xlsx xlt xltx",
"ReportsDocSearchFileExt": "csv doc docx dot dotx pdf pot potx pps ppsx ppt pptx txt xls xlsx xlt xltx",
"ReportsDocSearchKeywords": "phi pii ssn",
"SiteAttestation": false,
Expand Down
8 changes: 8 additions & 0 deletions spfx/src/webparts/siteAdmin/SiteAdminWebPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface ISiteAdminWebPartProps {
MaxStorage: number;
MaxStorageDescription: string;
ReportsDocRententionYears: string;
ReportsDLPFileExt: string;
ReportsDocSearchFileExt: string;
ReportsDocSearchKeywords: string;
SiteAttestation: boolean;
Expand Down Expand Up @@ -138,6 +139,7 @@ declare const SiteAdmin: {
siteAttestationText?: string;
reportProps?: {
docRententionYears?: string;
dlpFileExt?: string;
docSearchFileExt?: string;
docSearchKeywords?: string;
}
Expand Down Expand Up @@ -222,6 +224,7 @@ export default class SiteAdminWebPart extends BaseClientSideWebPart<ISiteAdminWe
maxStorageDesc: this.properties.MaxStorageDescription,
maxStorageSize: this.properties.MaxStorage,
reportProps: {
dlpFileExt: this.properties.ReportsDLPFileExt,
docRententionYears: this.properties.ReportsDocRententionYears,
docSearchFileExt: this.properties.ReportsDocSearchFileExt,
docSearchKeywords: this.properties.ReportsDocSearchKeywords
Expand Down Expand Up @@ -432,6 +435,11 @@ export default class SiteAdminWebPart extends BaseClientSideWebPart<ISiteAdminWe
{
groupName: "Audit Tools",
groupFields: [
PropertyPaneTextField("ReportsDLPFileExt", {
label: strings.ReportsDLPFileExt,
description: "The default file extensions to search.",
value: this.properties.ReportsDLPFileExt
}),
PropertyPaneDropdown("ReportsDocRententionYears", {
label: strings.ReportsDocRententionYears,
selectedKey: this.properties.ReportsDocRententionYears,
Expand Down
1 change: 1 addition & 0 deletions spfx/src/webparts/siteAdmin/loc/en-us.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ define([], function () {
"AppTitle": "App Title",
"MaxStorage": "Max Storage Allowed",
"MaxStorageDescription": "Max Storage Description",
"ReportsDLPFileExt": "DLP Default File Extensions",
"ReportsDocRententionYears": "Document Retention Default Years",
"ReportsDocSearchFileExt": "Document Search Default File Extensions",
"ReportsDocSearchKeywords": "Document Search Default Keywords",
Expand Down
1 change: 1 addition & 0 deletions spfx/src/webparts/siteAdmin/loc/mystrings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ declare interface ISiteAdminWebPartStrings {
AppTitle: string;
MaxStorage: string;
MaxStorageDescription: string;
ReportsDLPFileExt: string;
ReportsDocRententionYears: string;
ReportsDocSearchFileExt: string;
ReportsDocSearchKeywords: string;
Expand Down
2 changes: 1 addition & 1 deletion src/ds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ export class DataSource {
LoadingDialog.setBody("Validating the site '" + url + "'");

// Validate the url and resolve the request
this.validate(url).then(resolve, resolve);
this.validate(decodeURIComponent(url)).then(resolve, resolve);
} else {
// Resolve the request
resolve();
Expand Down
94 changes: 62 additions & 32 deletions src/reports/dlp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ export class DLP {
private static _items: IDLPItem[] = [];

// Gets the form fields to display
static getFormFields(): Components.IFormControlProps[] { return []; }
static getFormFields(fileExt: string = ""): Components.IFormControlProps[] {
return [
{
label: "File Types",
name: "FileTypes",
className: "mb-3",
type: Components.FormControlTypes.TextField,
value: fileExt
}
];
}

// Analyzes a single library
static analyzeLibrary(webId: string, webUrl: string, libId: string, libTitle: string) {
Expand Down Expand Up @@ -113,7 +123,7 @@ export class DLP {
Modal.setHeader("Data Loss Prevention Report");

// Show the results
this.renderSummary(Modal.BodyElement, false, null);
this.renderSummary(Modal.BodyElement, false, false);

// Render the footer
Components.ButtonGroup({
Expand All @@ -137,7 +147,7 @@ export class DLP {
}

// Analyzes the libraries
private static analyzeLibraries(webId: string, webUrl: string, libraries: Types.SP.ListOData[]) {
private static analyzeLibraries(webId: string, webUrl: string, libraries: Types.SP.ListOData[], fileExtensions: string[]) {
// Return a promise
return new Promise(resolve => {
let counter = 0;
Expand All @@ -162,33 +172,50 @@ export class DLP {

// Parse the items and create the batch job
items.results.forEach(item => {
// Increment the counter
batchRequests++;

// Create a batch request to get the dlp policy on this item
list.Items(item.Id).GetDlpPolicyTip().batch(result => {
// Ensure a policy exists
if (typeof (result["GetDlpPolicyTip"]) === "undefined") {
// Parse the conditions
result.MatchedConditionDescriptions.results.forEach(condition => {
// Append the data
this._items.push({
AppliedActionsText: result.AppliedActionsText,
Author: item["Author"]?.Title,
ConditionDescription: condition,
FileExtension: item["File_x0020_Type"],
FileName: item["FileLeafRef"],
GeneralText: result.GeneralText,
LastProcessedTime: result.LastProcessedTime,
ListId: lib.Id,
ListTitle: lib.Title,
Path: item["FileRef"],
WebId: webId,
WebUrl: webUrl
let analyzeFile = true;

// See if the file extensions are provided
if (fileExtensions) {
// Default the flag
analyzeFile = false

// Loop through the file extensions
fileExtensions.forEach(fileExt => {
// Set the flag if there is match
if (fileExt.toLowerCase() == item["File_x0020_Type"]?.toLowerCase()) { analyzeFile = true; }
});
}

// See if we are analyzing this file
if (analyzeFile) {
// Increment the counter
batchRequests++;

// Create a batch request to get the dlp policy on this item
list.Items(item.Id).GetDlpPolicyTip().batch(result => {
// Ensure a policy exists
if (typeof (result["GetDlpPolicyTip"]) === "undefined") {
// Parse the conditions
result.MatchedConditionDescriptions.results.forEach(condition => {
// Append the data
this._items.push({
AppliedActionsText: result.AppliedActionsText,
Author: item["Author"]?.Title,
ConditionDescription: condition,
FileExtension: item["File_x0020_Type"],
FileName: item["FileLeafRef"],
GeneralText: result.GeneralText,
LastProcessedTime: result.LastProcessedTime,
ListId: lib.Id,
ListTitle: lib.Title,
Path: item["FileRef"],
WebId: webId,
WebUrl: webUrl
});
});
});
}
});
}
});
}
});

// Update the dialog
Expand All @@ -203,7 +230,7 @@ export class DLP {
}

// Renders the search summary
private static renderSummary(el: HTMLElement, auditOnly: boolean, onClose: () => void) {
private static renderSummary(el: HTMLElement, auditOnly: boolean, showSearch?: boolean, onClose?: () => void) {
// Render the summary
new Dashboard({
el,
Expand Down Expand Up @@ -328,6 +355,9 @@ export class DLP {
LoadingDialog.setBody("Loading the libraries...");
LoadingDialog.show();

// Get the file extensions
let fileExtensions: string[] = values["FileTypes"] ? values["FileTypes"].trim().split(' ') : [];

// Parse the webs
let counter = 0;
Helper.Executor(DataSource.SiteItems, siteItem => {
Expand Down Expand Up @@ -358,15 +388,15 @@ export class DLP {
LoadingDialog.setBody("Loading the files for the libraries...");

// Analyze the libraries
this.analyzeLibraries(siteItem.value, siteItem.text, libs.results).then(resolve);
this.analyzeLibraries(siteItem.value, siteItem.text, libs.results, fileExtensions).then(resolve);
});
});
}).then(() => {
// Clear the element
while (el.firstChild) { el.removeChild(el.firstChild); }

// Render the summary
this.renderSummary(el, auditOnly, onClose);
this.renderSummary(el, auditOnly, true, onClose);

// Hide the loading dialog
LoadingDialog.hide();
Expand Down
4 changes: 2 additions & 2 deletions src/tabs/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class ListsTab {
el.innerHTML = `
<span><b>Name: </b>${item.ListName}</span>
<br/>
<span><b>Type: </b>${item.ListTemplate}</span>
<span><b>Type: </b>${item.ListTemplate || ""}</span>
`;
}
},
Expand Down Expand Up @@ -548,7 +548,7 @@ export class ListsTab {
{
name: "SearchAll",
type: Components.FormControlTypes.Switch,
label: "Search All Sub-Webs?",
label: "Search All Sub-Sites?",
description: "Select this option to search all webs in this site.",
value: true,
onChange: (item => {
Expand Down
3 changes: 2 additions & 1 deletion src/tabs/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ISearchProps } from "./searchProp";

// Report Properties
export interface IReportProps {
dlpFileExt?: string;
docRententionYears?: string;
docSearchFileExt?: string;
docSearchKeywords?: string;
Expand Down Expand Up @@ -138,7 +139,7 @@ export class ReportsTab {
// Add the controls
switch (selectedReport) {
case ReportTypes.DLP:
form.appendControls(Reports.DLP.getFormFields());
form.appendControls(Reports.DLP.getFormFields(this._reportProps?.dlpFileExt));
break;
case ReportTypes.DocRetention:
form.appendControls(Reports.DocRetention.getFormFields(this._reportProps.docRententionYears));
Expand Down
Loading