Skip to content

Commit

Permalink
- Added Rule in Ruleset to make the this. rule a warning
Browse files Browse the repository at this point in the history
- Added Instructions for the Sentinel Tool on the Alert list
- Improved documentation on Rule 1-3
  • Loading branch information
StefanMaron committed Dec 8, 2024
1 parent 34f0c79 commit 22ee4eb
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 57 deletions.
42 changes: 35 additions & 7 deletions BusinessCentral.Sentinel/src/AlertList.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@ page 71180275 AlertListSESTM
SourceTable = AlertSESTM;
UsageCategory = Lists;


layout
{
area(Content)
{
group(Instructions)
{
Caption = 'Instructions';

field(Usage; this.InstructionsLbl)
{
Editable = false;
MultiLine = true;
ShowCaption = false;
}
}
repeater(Group)
{
field(Id; Rec.Id)
Expand All @@ -28,7 +38,7 @@ page 71180275 AlertListSESTM
{
AboutText = 'The code representing the type of alert. You may see more than one alert with the same code if the same issue is detected multiple times.';
AboutTitle = 'Alert Code';
StyleExpr = SeverityStyle;
StyleExpr = this.SeverityStyle;
}
field("Short Description"; Rec."ShortDescription")
{
Expand Down Expand Up @@ -134,7 +144,7 @@ page 71180275 AlertListSESTM
{
Caption = 'More Details';
Ellipsis = true;
Image = ViewDetails;
Image = LaunchWeb;
Scope = Repeater;
ToolTip = 'Show more details about this alert.';

Expand Down Expand Up @@ -162,6 +172,22 @@ page 71180275 AlertListSESTM
IAuditAlert.AutoFix(Rec);
end;
}
action(ShowRelatedInformation)
{
Caption = 'Show Related Information';
Ellipsis = true;
Image = ViewDetails;
Scope = Repeater;
ToolTip = 'Show related information about this alert.';

trigger OnAction()
var
IAuditAlert: Interface IAuditAlertSESTM;
begin
IAuditAlert := Rec.AlertCode;
IAuditAlert.ShowRelatedInformation(Rec);
end;
}
}
area(Navigation)
{
Expand Down Expand Up @@ -189,11 +215,13 @@ page 71180275 AlertListSESTM
actionref(ClearIgnore_Promoted; ClearIgnore) { }
}
actionref(MoreDetails_Promoted; MoreDetails) { }
actionref(ShowRelatedInformation_Promoted; ShowRelatedInformation) { }
actionref(AutoFix_Promoted; AutoFix) { }
}
}

var
InstructionsLbl: Label 'This page shows a list of all alerts that have been found for your environment.\Its important to understand that those alerts are recommendations and should be reviewed before taking any action.\Not all alerts may be relevant to your environment or your business processes.\\You can collapse this message by a click on "Instructions" above.';
SeverityStyle: Text;

trigger OnOpenPage()
Expand All @@ -205,13 +233,13 @@ page 71180275 AlertListSESTM
begin
case Rec.Severity of
SeveritySESTM::Info:
SeverityStyle := Format(PageStyle::StandardAccent);
this.SeverityStyle := Format(PageStyle::StandardAccent);
SeveritySESTM::Warning:
SeverityStyle := Format(PageStyle::Ambiguous);
this.SeverityStyle := Format(PageStyle::Ambiguous);
SeveritySESTM::Error:
SeverityStyle := Format(PageStyle::Attention);
this.SeverityStyle := Format(PageStyle::Attention);
SeveritySESTM::Critical:
SeverityStyle := Format(PageStyle::Unfavorable);
this.SeverityStyle := Format(PageStyle::Unfavorable);
end;
end;

Expand Down
12 changes: 7 additions & 5 deletions BusinessCentral.Sentinel/src/Rules/AlertDevScopeExt.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ codeunit 71180277 AlertDevScopeExtSESTM implements IAuditAlertSESTM
var
Alert: Record AlertSESTM;
Extensions: Record "NAV App Installed App";
ActionRecommendationLbl: Label 'Talk to the third party that developed the extension and ask them to publish the extension in PTE scope instead.';
LongDescLbl: Label 'Extension in DEV Scope will get uninstalled when the environment is upgraded to a newer version. Publishing them in PTE scope instead will prevent this.';
ShortDescLbl: Label 'Extension in DEV Scope found: %1', Comment = '%1 = Extension Name';
ActionRecommendationLbl: Label 'Talk to the developer that developed the extension and ask them to publish the extension in PTE scope instead.';
LongDescLbl: Label 'Extension in DEV Scope will get uninstalled when the environment is upgraded to a newer version. This can be Minor updates (monthly) or Major updates (bi-yearly). Publishing them in PTE scope instead will prevent this and make sure the business processes are not interrupted.';
ShortDescLbl: Label 'Extension in DEV Scope found: Name: "%1" AppId: "%2"', Comment = '%1 = Extension Name, %2 = App ID';
begin
Extensions.SetRange("Published As", Extensions."Published As"::Dev);
Extensions.ReadIsolation(IsolationLevel::ReadUncommitted);
Expand All @@ -26,7 +26,7 @@ codeunit 71180277 AlertDevScopeExtSESTM implements IAuditAlertSESTM
repeat
Alert.New(
AlertCodeSESTM::"SE-000002",
StrSubstNo(ShortDescLbl, Extensions."Name"),
StrSubstNo(ShortDescLbl, Extensions."Name", DelChr(Extensions."App ID", '=', '{}')),
SeveritySESTM::Warning,
AreaSESTM::Technical,
LongDescLbl,
Expand All @@ -52,7 +52,9 @@ codeunit 71180277 AlertDevScopeExtSESTM implements IAuditAlertSESTM
end;

procedure AutoFix(var Alert: Record AlertSESTM)
var
NoAutofixAvailableLbl: Label 'No autofix available for this alert. (SE-000001)';
begin

Message(NoAutofixAvailableLbl);
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ codeunit 71180276 AlertPteDownloadCodeSESTM implements IAuditAlertSESTM
Alert: Record AlertSESTM;
Extensions: Record "NAV App Installed App";
ActionRecommendationLbl: Label 'Talk to the third party that developed the extension and ask for a copy of the code or to enable the download code option.';
LongDescLbl: Label 'Per Tenant Extension does not allow Download Code, if the code was developed for you by a third party, you might want to make sure to have access to the code in case you need to make changes in the future and the third party is not available anymore.';
ShortDescLbl: Label 'Download Code not allowed for PTE: %1', Comment = '%1 = Extension Name';
LongDescLbl: Label 'The Per Tenant Extension does not allow Download Code, if the code was developed for you by a third party, you might want to make sure to have access to the code in case you need to make changes in the future and the third party is not available anymore. If you have access to the source, for example, because you developed the extension yourself or you have been granted access though another way, like GitHub, you can ignore this alert.';
ShortDescLbl: Label 'Download Code not allowed for PTE: Name: "%1" AppId: "%2"', Comment = '%1 = Extension Name, %2 = App ID';
begin
Extensions.SetRange("Published As", Extensions."Published As"::PTE);
Extensions.ReadIsolation(IsolationLevel::ReadUncommitted);
Expand All @@ -27,7 +27,7 @@ codeunit 71180276 AlertPteDownloadCodeSESTM implements IAuditAlertSESTM
if not this.CanDownloadSourceCode(Extensions."Package ID") then
Alert.New(
"AlertCodeSESTM"::"SE-000001",
StrSubstNo(ShortDescLbl, Extensions."Name"),
StrSubstNo(ShortDescLbl, Extensions."Name", DelChr(Extensions."App ID", '=', '{}')),
SeveritySESTM::Warning,
AreaSESTM::Technical,
LongDescLbl,
Expand Down Expand Up @@ -62,7 +62,9 @@ codeunit 71180276 AlertPteDownloadCodeSESTM implements IAuditAlertSESTM
end;

procedure AutoFix(var Alert: Record AlertSESTM)
var
NoAutofixAvailableLbl: Label 'No autofix available for this alert. (SE-000001)';
begin

Message(NoAutofixAvailableLbl);
end;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace STM.BusinessCentral.Sentinel;

using Microsoft.Foundation.Company;
using STM.BusinessCentral.Sentinel;
using System.Environment;
using System.Environment.Configuration;
Expand All @@ -17,7 +18,7 @@ codeunit 71180278 EvaluationCompanyInProdSESTM implements IAuditAlertSESTM
Company: Record Company;
EnvironmentInformation: Codeunit "Environment Information";
CallToActionLbl: Label 'Delete the Company called %1', Comment = '%1 = Company Name';
LongDescLbl: Label 'An evaluation company has been detected in the environment. If you do not need it anymore, you should consider deleting it.';
LongDescLbl: Label 'An evaluation company has been detected in the environment. If you do not need it anymore, you should consider deleting it. It takes up additional space and it is copied to sandboxes if you copy from production.';
ShortDescLbl: Label 'Evaluation Company detected: %1', Comment = '%1 = Company Name';
begin
Company.SetRange("Evaluation Company", true);
Expand Down Expand Up @@ -47,12 +48,22 @@ codeunit 71180278 EvaluationCompanyInProdSESTM implements IAuditAlertSESTM
end;

procedure ShowRelatedInformation(var Alert: Record AlertSESTM)
var
Company: Record Company;
OpenPageQst: Label 'Do you want to open the page to manage companies?';
begin

if Confirm(OpenPageQst) then begin
Company.SetRange(SystemId, Alert.UniqueIdentifier);
Page.Run(Page::Companies, Company)
end;
end;

procedure AutoFix(var Alert: Record AlertSESTM)
var
NoAutofixAvailableLbl: Label 'No autofix available for this alert. (SE-000001)';
begin

// The base BC logic that happens on delete company is on the page, and can not be reused
// Therefore, the user has to use the ShowRelatedInformation to open the page and delete from there.
Message(NoAutofixAvailableLbl);
end;
}
48 changes: 24 additions & 24 deletions BusinessCentral.Sentinel/src/Rules/NonPostNoSeriesGaps.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ codeunit 71180281 NonPostNoSeriesGapsSESTM implements IAuditAlertSESTM
Access = Internal;
Permissions =
tabledata AlertSESTM = RI,
tabledata "Jobs Setup" = r,
tabledata "No. Series" = R,
tabledata "No. Series Line" = R,
tabledata "Jobs Setup" = r,
tabledata "Purchases & Payables Setup" = R,
tabledata "Sales & Receivables Setup" = R;

procedure CreateAlerts()
begin
CheckSalesSetup();
CheckPurchaseSetup();
CheckJobsSetup();
this.CheckSalesSetup();
this.CheckPurchaseSetup();
this.CheckJobsSetup();
end;

local procedure CheckPurchaseSetup()
Expand All @@ -33,14 +33,14 @@ codeunit 71180281 NonPostNoSeriesGapsSESTM implements IAuditAlertSESTM
if not PurchaseSetup.Get() then
exit;

CheckNoSeries(PurchaseSetup."Order Nos.");
CheckNoSeries(PurchaseSetup."Invoice Nos.");
CheckNoSeries(PurchaseSetup."Credit Memo Nos.");
CheckNoSeries(PurchaseSetup."Quote Nos.");
CheckNoSeries(PurchaseSetup."Vendor Nos.");
CheckNoSeries(PurchaseSetup."Blanket Order Nos.");
CheckNoSeries(PurchaseSetup."Price List Nos.");
CheckNoSeries(PurchaseSetup."Return Order Nos.");
this.CheckNoSeries(PurchaseSetup."Order Nos.");
this.CheckNoSeries(PurchaseSetup."Invoice Nos.");
this.CheckNoSeries(PurchaseSetup."Credit Memo Nos.");
this.CheckNoSeries(PurchaseSetup."Quote Nos.");
this.CheckNoSeries(PurchaseSetup."Vendor Nos.");
this.CheckNoSeries(PurchaseSetup."Blanket Order Nos.");
this.CheckNoSeries(PurchaseSetup."Price List Nos.");
this.CheckNoSeries(PurchaseSetup."Return Order Nos.");
end;

local procedure CheckSalesSetup()
Expand All @@ -52,16 +52,16 @@ codeunit 71180281 NonPostNoSeriesGapsSESTM implements IAuditAlertSESTM
if not SalesSetup.Get() then
exit;

CheckNoSeries(SalesSetup."Order Nos.");
CheckNoSeries(SalesSetup."Invoice Nos.");
CheckNoSeries(SalesSetup."Credit Memo Nos.");
CheckNoSeries(SalesSetup."Quote Nos.");
CheckNoSeries(SalesSetup."Customer Nos.");
CheckNoSeries(SalesSetup."Blanket Order Nos.");
CheckNoSeries(SalesSetup."Reminder Nos.");
CheckNoSeries(SalesSetup."Fin. Chrg. Memo Nos.");
CheckNoSeries(SalesSetup."Direct Debit Mandate Nos.");
CheckNoSeries(SalesSetup."Price List Nos.");
this.CheckNoSeries(SalesSetup."Order Nos.");
this.CheckNoSeries(SalesSetup."Invoice Nos.");
this.CheckNoSeries(SalesSetup."Credit Memo Nos.");
this.CheckNoSeries(SalesSetup."Quote Nos.");
this.CheckNoSeries(SalesSetup."Customer Nos.");
this.CheckNoSeries(SalesSetup."Blanket Order Nos.");
this.CheckNoSeries(SalesSetup."Reminder Nos.");
this.CheckNoSeries(SalesSetup."Fin. Chrg. Memo Nos.");
this.CheckNoSeries(SalesSetup."Direct Debit Mandate Nos.");
this.CheckNoSeries(SalesSetup."Price List Nos.");
end;

local procedure CheckJobsSetup()
Expand All @@ -73,8 +73,8 @@ codeunit 71180281 NonPostNoSeriesGapsSESTM implements IAuditAlertSESTM
if not JobsSetup.Get() then
exit;

CheckNoSeries(JobsSetup."Job Nos.");
CheckNoSeries(JobsSetup."Price List Nos.");
this.CheckNoSeries(JobsSetup."Job Nos.");
this.CheckNoSeries(JobsSetup."Price List Nos.");
end;

local procedure CheckNoSeries(NoSeriesCode: Code[20])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ codeunit 71180283 UnusedExtensionInstalledSESTM implements IAuditAlertSESTM
IntercompanyAPITok: Label 'a190e87b-2f59-4e14-a727-421877802768', Locked = true;
ShopifyConnectorIdTok: Label 'ec255f57-31d0-4ca2-b751-f2fa7c745abb', Locked = true;
begin
RaiseAlertIfExtensionIsUnused(ShopifyConnectorIdTok, 30102);
RaiseAlertIfExtensionIsUnused(AMCBankingTok, 20101);
RaiseAlertIfExtensionIsUnused(IntercompanyAPITok, 413);
RaiseAlertIfExtensionIsUnused(CloudMigrationTok);
RaiseAlertIfExtensionIsUnused(CloudMigrationApiTok);
RaiseAlertIfExtensionIsUnused(IntelligentCloudTok);
RaiseAlertIfExtensionIsUnused(CeridianPayrollTok, 1665);
this.RaiseAlertIfExtensionIsUnused(ShopifyConnectorIdTok, 30102);
this.RaiseAlertIfExtensionIsUnused(AMCBankingTok, 20101);
this.RaiseAlertIfExtensionIsUnused(IntercompanyAPITok, 413);
this.RaiseAlertIfExtensionIsUnused(CloudMigrationTok);
this.RaiseAlertIfExtensionIsUnused(CloudMigrationApiTok);
this.RaiseAlertIfExtensionIsUnused(IntelligentCloudTok);
this.RaiseAlertIfExtensionIsUnused(CeridianPayrollTok, 1665);
end;

local procedure RaiseAlertIfExtensionIsUnused(AppId: Text)
var
TablesToVerify: List of [Integer];
begin
RaiseAlertIfExtensionIsUnused(AppId, TablesToVerify);
this.RaiseAlertIfExtensionIsUnused(AppId, TablesToVerify);
end;

local procedure RaiseAlertIfExtensionIsUnused(AppId: Text; TableToVerify: Integer)
var
TablesToVerify: List of [Integer];
begin
TablesToVerify.Add(TableToVerify);
RaiseAlertIfExtensionIsUnused(AppId, TablesToVerify);
this.RaiseAlertIfExtensionIsUnused(AppId, TablesToVerify);
end;

local procedure RaiseAlertIfExtensionIsUnused(AppId: Text; TablesToVerify: List of [Integer])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ codeunit 71180280 UserWithSuperSESTM implements IAuditAlertSESTM
AreaSESTM::Permissions,
StrSubstNo(LongDescLbl, User."User Name", AccessControl."Company Name"),
StrSubstNo(ActionRecommendationLbl, User."User Name", AccessControl."Company Name"),
CreateUniqueIdentifier(AccessControl)
this.CreateUniqueIdentifier(AccessControl)
);
until AccessControl.Next() = 0;
until User.Next() = 0;
Expand Down
2 changes: 2 additions & 0 deletions BusinessCentral.Sentinel/src/SentinelRuleSet.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ table 71180277 SentinelRuleSetSESTM
Access = Internal;
Caption = 'Sentinel Rule Set';
DataClassification = CustomerContent;
DrillDownPageId = SentinelRuleSetSESTM;
LookupPageId = SentinelRuleSetSESTM;

fields
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ codeunit 71180284 "TelemetryHelperSESTM"
var
FeatureTelemetry: Codeunit "Feature Telemetry";
begin
if not IsSaaS() then
if not this.IsSaaS() then
exit;

FeatureTelemetry.LogUptake(
Expand All @@ -25,7 +25,7 @@ codeunit 71180284 "TelemetryHelperSESTM"
var
FeatureTelemetry: Codeunit "Feature Telemetry";
begin
if not IsSaaS() then
if not this.IsSaaS() then
exit;

FeatureTelemetry.LogError(
Expand All @@ -40,7 +40,7 @@ codeunit 71180284 "TelemetryHelperSESTM"
var
FeatureTelemetry: Codeunit "Feature Telemetry";
begin
if not IsSaaS() then
if not this.IsSaaS() then
exit;

FeatureTelemetry.LogUsage(
Expand All @@ -54,7 +54,7 @@ codeunit 71180284 "TelemetryHelperSESTM"
var
FeatureTelemetry: Codeunit "Feature Telemetry";
begin
if not IsSaaS() then
if not this.IsSaaS() then
exit;

FeatureTelemetry.LogUsage(
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
[Full Changelog](https://github.com/StefanMaron/BusinessCentral.Sentinel/compare/1.4.22...HEAD)

**Changes:**
- Added JobsSetup to NoSeries Checks Merge pull request [\#6](https://github.com/StefanMaron/BusinessCentral.Sentinel/pull/6) from [pri-kise](https://github.com/pri-kise)
- Added Rule in Ruleset to make the `this.` rule a warning
- Added Instructions for the Sentinel Tool on the Alert list
- Improved documentation on Rule 1-3

**Closed Issues:**
- Improve Rule SE-000007, there where cases where the App Name was not shown, also display the App ID [\#7](https://github.com/StefanMaron/BusinessCentral.Sentinel/issues/7)
Expand Down
Loading

0 comments on commit 22ee4eb

Please sign in to comment.