Skip to content

Commit

Permalink
Rule0015 Show warning if table data permission is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanMaron committed Jan 26, 2022
1 parent 56c923f commit eae67f9
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Design/Rule0015PermissionSetCoverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ private void CheckPermissionSetCoverage(SymbolAnalysisContext context)
PermissionObjectKind permObjectKind = PermissionObjectKind.Table;
int permObjectId = appObjTypeSymbol.Id;

if (appObjTypeSymbol.IsObsoleteRemoved)
{
continue;
}

switch (appObjTypeSymbol.NavTypeKind)
{
case NavTypeKind.Codeunit:
Expand All @@ -57,24 +62,25 @@ private void CheckPermissionSetCoverage(SymbolAnalysisContext context)
case NavTypeKind.Report:
permObjectKind = PermissionObjectKind.Report;
break;
case NavTypeKind.Table:
case NavTypeKind.Record:
permObjectKind = PermissionObjectKind.Table;
break;
case NavTypeKind.XmlPort:
permObjectKind = PermissionObjectKind.Xmlport;
break;
}

if (appObjTypeSymbol.IsObsoleteRemoved)
{
continue;
}
if (permissionSymbols.Contains((permObjectKind, permObjectId)) || permissionSymbols.Contains((permObjectKind, 0)) || XmlPermissionExistsForObject(permissionSetDocuments, permObjectKind, permObjectId))
if (!(permissionSymbols.Contains((permObjectKind, permObjectId)) || permissionSymbols.Contains((permObjectKind, 0)) || XmlPermissionExistsForObject(permissionSetDocuments, permObjectKind, permObjectId)))
context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0015PermissionSetCoverage, current.GetLocation(), new Object[] { permObjectKind.ToString(), appObjTypeSymbol.Name }));

if (appObjTypeSymbol.NavTypeKind == NavTypeKind.Record)
{
continue;
permObjectKind = PermissionObjectKind.TableData;

if (!(permissionSymbols.Contains((permObjectKind, permObjectId)) || permissionSymbols.Contains((permObjectKind, 0)) || XmlPermissionExistsForObject(permissionSetDocuments, permObjectKind, permObjectId)))
context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0015PermissionSetCoverage, current.GetLocation(), new Object[] { permObjectKind.ToString(), appObjTypeSymbol.Name }));
}

context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0015PermissionSetCoverage, current.GetLocation(), new Object[] { permObjectKind.ToString(), appObjTypeSymbol.Name }));
}
}

Expand Down

0 comments on commit eae67f9

Please sign in to comment.