diff --git a/.vscode/launch.json b/.vscode/launch.json index 25aef37..caf449e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,8 +12,8 @@ // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/bin/Debug/net5.0/SFGrantReport.dll", //"args": ["-l", "C:\\snowflake\\SnowflakeGrantReport\\Reports\\aws_cas1", "-r", "C:\\snowflake\\SnowflakeGrantReport\\Reports\\aws_cas1.offline.08192021", "-o", "C:\\snowflake\\SnowflakeGrantReport\\Reports\\aws_cas1.offline.08192021.compare" ], - //"args": ["-i", "C:\\snowflake\\GrantReport\\ACCOUNT_USAGE_INPUT\\", "-o", "C:\\snowflake\\SnowflakeGrantReport\\Reports\\Avalera\\myReports", "-s"], - "args": ["-c", "sfgrantreport", "-o", "C:\\snowflake\\SnowflakeGrantReport\\Reports\\Avalera\\myReports", "-s"], + "args": ["-i", "C:\\snowflake\\SnowflakeGrantReport\\ACCOUNT_USAGE_INPUT\\COINBASE_Snowhouse", "-o", "C:\\snowflake\\SnowflakeGrantReport\\Reports\\COINBASE.20220314"], + //"args": ["-c", "sfgrantreport", "-o", "C:\\snowflake\\SnowflakeGrantReport\\Reports\\Avalera\\myReports", "-s"], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console "console": "externalTerminal", diff --git a/ProcessingSteps/Report/ReportUserRoleGrantHierarchyGraphViz.cs b/ProcessingSteps/Report/ReportUserRoleGrantHierarchyGraphViz.cs index 91b6b35..8bf68ef 100644 --- a/ProcessingSteps/Report/ReportUserRoleGrantHierarchyGraphViz.cs +++ b/ProcessingSteps/Report/ReportUserRoleGrantHierarchyGraphViz.cs @@ -220,7 +220,10 @@ public override bool Execute(ProgramOptions programOptions) break; } - sbGraphViz.AppendFormat(" {0}{1}{2}", schema.ShortName, schema.Tables.Count, schema.Views.Count); sbGraphViz.AppendLine(); + // Do not output future grants which are in form of + if (schema.ShortName.StartsWith("<") && schema.ShortName.EndsWith(">")) continue; + + sbGraphViz.AppendFormat(" {0}{1}{2}", System.Web.HttpUtility.HtmlEncode(schema.ShortName), schema.Tables.Count, schema.Views.Count); sbGraphViz.AppendLine(); schemaLimit++; } diff --git a/ProcessingSteps/Report/ReportUserRoleGrantsTable.cs b/ProcessingSteps/Report/ReportUserRoleGrantsTable.cs index 0e35d81..be95b73 100644 --- a/ProcessingSteps/Report/ReportUserRoleGrantsTable.cs +++ b/ProcessingSteps/Report/ReportUserRoleGrantsTable.cs @@ -914,7 +914,7 @@ private void generateExcelReport(ProgramOptions programOptions, List she // Add another Role to the header thisRoleColumnIndex = roleColumnMaxIndex; roleToHeaderMapping.Add(firstGrant.GrantedTo, thisRoleColumnIndex); - sheet.Cells[headerRowIndex, thisRoleColumnIndex].Value = firstGrant.GrantedTo; + if (thisRoleColumnIndex <= 16384) sheet.Cells[headerRowIndex, thisRoleColumnIndex].Value = firstGrant.GrantedTo; roleColumnMaxIndex++; } else @@ -922,7 +922,7 @@ private void generateExcelReport(ProgramOptions programOptions, List she // Previously seen thisRoleColumnIndex = roleToHeaderMapping[firstGrant.GrantedTo]; } - outputGrantstToCell(sheet.Cells[currentRowIndex, thisRoleColumnIndex], grantsByRoleNameGroup.ToList()); + if (thisRoleColumnIndex <= 16384) outputGrantstToCell(sheet.Cells[currentRowIndex, thisRoleColumnIndex], grantsByRoleNameGroup.ToList()); } currentRowIndex++; @@ -944,7 +944,7 @@ private void generateExcelReport(ProgramOptions programOptions, List she // Add another Role to the header thisRoleColumnIndex = roleColumnMaxIndex; roleToHeaderMapping.Add(firstGrant.GrantedTo, thisRoleColumnIndex); - sheet.Cells[headerRowIndex, thisRoleColumnIndex].Value = firstGrant.GrantedTo; + if (thisRoleColumnIndex <= 16384) sheet.Cells[headerRowIndex, thisRoleColumnIndex].Value = firstGrant.GrantedTo; roleColumnMaxIndex++; } else @@ -952,7 +952,7 @@ private void generateExcelReport(ProgramOptions programOptions, List she // Previously seen thisRoleColumnIndex = roleToHeaderMapping[firstGrant.GrantedTo]; } - outputGrantstToCell(sheet.Cells[currentRowIndex, thisRoleColumnIndex], grantsByRoleNameGroup.ToList()); + if (thisRoleColumnIndex <= 16384) outputGrantstToCell(sheet.Cells[currentRowIndex, thisRoleColumnIndex], grantsByRoleNameGroup.ToList()); } currentRowIndex++; @@ -974,7 +974,7 @@ private void generateExcelReport(ProgramOptions programOptions, List she // Add another Role to the header thisRoleColumnIndex = roleColumnMaxIndex; roleToHeaderMapping.Add(firstGrant.GrantedTo, thisRoleColumnIndex); - sheet.Cells[headerRowIndex, thisRoleColumnIndex].Value = firstGrant.GrantedTo; + if (thisRoleColumnIndex <= 16384) sheet.Cells[headerRowIndex, thisRoleColumnIndex].Value = firstGrant.GrantedTo; roleColumnMaxIndex++; } else @@ -982,7 +982,7 @@ private void generateExcelReport(ProgramOptions programOptions, List she // Previously seen thisRoleColumnIndex = roleToHeaderMapping[firstGrant.GrantedTo]; } - outputGrantstToCell(sheet.Cells[currentRowIndex, thisRoleColumnIndex], grantsByRoleNameGroup.ToList()); + if (thisRoleColumnIndex <= 16384) outputGrantstToCell(sheet.Cells[currentRowIndex, thisRoleColumnIndex], grantsByRoleNameGroup.ToList()); } sheet.Row(currentRowIndex).OutlineLevel = 1; @@ -1006,7 +1006,7 @@ private void generateExcelReport(ProgramOptions programOptions, List she // Add another Role to the header thisRoleColumnIndex = roleColumnMaxIndex; roleToHeaderMapping.Add(firstGrant.GrantedTo, thisRoleColumnIndex); - sheet.Cells[headerRowIndex, thisRoleColumnIndex].Value = firstGrant.GrantedTo; + if (thisRoleColumnIndex <= 16384) sheet.Cells[headerRowIndex, thisRoleColumnIndex].Value = firstGrant.GrantedTo; roleColumnMaxIndex++; } else @@ -1014,7 +1014,7 @@ private void generateExcelReport(ProgramOptions programOptions, List she // Previously seen thisRoleColumnIndex = roleToHeaderMapping[firstGrant.GrantedTo]; } - outputGrantstToCell(sheet.Cells[currentRowIndex, thisRoleColumnIndex], grantsByRoleNameGroup.ToList()); + if (thisRoleColumnIndex <= 16384) outputGrantstToCell(sheet.Cells[currentRowIndex, thisRoleColumnIndex], grantsByRoleNameGroup.ToList()); } sheet.Row(currentRowIndex).OutlineLevel = 1; @@ -1050,39 +1050,43 @@ private void generateExcelReport(ProgramOptions programOptions, List she } // Format the cells - ExcelRangeBase rangeToFormat = sheet.Cells[headerRowIndex + 1, 4, sheet.Dimension.Rows, sheet.Dimension.Columns]; - rangeToFormat.StyleName = "ShortPermissionStyle"; - - var cfR = sheet.ConditionalFormatting.AddEqual(rangeToFormat); - cfR.Style.Font.Color.Color = Color.Green; - cfR.Style.Fill.BackgroundColor.Color = Color.LightGreen; - cfR.Formula = "=\"R\""; - - var cfCRUD = sheet.ConditionalFormatting.AddContainsText(rangeToFormat); - cfCRUD.Style.Font.Color.Color = Color.DarkRed; - cfCRUD.Style.Fill.BackgroundColor.Color = Color.Pink; - cfCRUD.Text = "C,R,U,D"; - - var cfCRU = sheet.ConditionalFormatting.AddContainsText(rangeToFormat); - cfCRU.Style.Font.Color.Color = Color.OrangeRed; - cfCRU.Style.Fill.BackgroundColor.Color = Color.Gold; - cfCRU.Text = "C,R,U"; - - var cfO = sheet.ConditionalFormatting.AddEqual(rangeToFormat); - cfO.Style.Font.Color.Color = Color.DarkBlue; - cfO.Style.Fill.BackgroundColor.Color = Color.Azure; - cfO.Formula = "=\"O\""; - - var cfOPlus = sheet.ConditionalFormatting.AddEqual(rangeToFormat); - cfOPlus.Style.Font.Color.Color = Color.DarkBlue; - cfOPlus.Style.Fill.BackgroundColor.Color = Color.LightBlue; - cfOPlus.Formula = "=\"O+\""; + // But only if the number of columns isn't insanely high + if (sheet.Dimension.Columns <=10000) + { + ExcelRangeBase rangeToFormat = sheet.Cells[headerRowIndex + 1, 4, sheet.Dimension.Rows, sheet.Dimension.Columns]; + rangeToFormat.StyleName = "ShortPermissionStyle"; + + var cfR = sheet.ConditionalFormatting.AddEqual(rangeToFormat); + cfR.Style.Font.Color.Color = Color.Green; + cfR.Style.Fill.BackgroundColor.Color = Color.LightGreen; + cfR.Formula = "=\"R\""; + + var cfCRUD = sheet.ConditionalFormatting.AddContainsText(rangeToFormat); + cfCRUD.Style.Font.Color.Color = Color.DarkRed; + cfCRUD.Style.Fill.BackgroundColor.Color = Color.Pink; + cfCRUD.Text = "C,R,U,D"; + + var cfCRU = sheet.ConditionalFormatting.AddContainsText(rangeToFormat); + cfCRU.Style.Font.Color.Color = Color.OrangeRed; + cfCRU.Style.Fill.BackgroundColor.Color = Color.Gold; + cfCRU.Text = "C,R,U"; + + var cfO = sheet.ConditionalFormatting.AddEqual(rangeToFormat); + cfO.Style.Font.Color.Color = Color.DarkBlue; + cfO.Style.Fill.BackgroundColor.Color = Color.Azure; + cfO.Formula = "=\"O\""; + + var cfOPlus = sheet.ConditionalFormatting.AddEqual(rangeToFormat); + cfOPlus.Style.Font.Color.Color = Color.DarkBlue; + cfOPlus.Style.Fill.BackgroundColor.Color = Color.LightBlue; + cfOPlus.Formula = "=\"O+\""; - rangeToFormat = sheet.Cells[headerRowIndex + 1, 3, sheet.Dimension.Rows, 3]; + rangeToFormat = sheet.Cells[headerRowIndex + 1, 3, sheet.Dimension.Rows, 3]; - var cfFuture = sheet.ConditionalFormatting.AddContainsText(rangeToFormat); - cfFuture.Style.Fill.BackgroundColor.Color = Color.GreenYellow; - cfFuture.Text = "<"; + var cfFuture = sheet.ConditionalFormatting.AddContainsText(rangeToFormat); + cfFuture.Style.Fill.BackgroundColor.Color = Color.GreenYellow; + cfFuture.Text = "<"; + } logger.Info("{0} Sheet ({1} rows)", sheet.Name, sheet.Dimension.Rows); loggerConsole.Info("{0} Sheet ({1} rows)", sheet.Name, sheet.Dimension.Rows); diff --git a/Snowflake.GrantReport.csproj b/Snowflake.GrantReport.csproj index 98fd063..0455e34 100644 --- a/Snowflake.GrantReport.csproj +++ b/Snowflake.GrantReport.csproj @@ -7,9 +7,9 @@ SFGrantReport Snowflake.GrantReport - 2021.10.12.0 - 2021.10.12.0 - 2021.10.12.0 + 2022.3.29.0 + 2022.3.29.0 + 2022.3.29.0 Daniel Odievich (daniel.odievich@snowflake.com) Snowflake Computing Snowflake Grant Report