Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[ODS-6175] Migrate GenerateSecurityGraphs to .NET 8 #933

Merged
merged 3 commits into from
Jan 29, 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
@@ -1,26 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Copyright>Copyright © 2020 Ed-Fi Alliance, LLC and Contributors</Copyright>
<TreatErrorsAsWarning>true</TreatErrorsAsWarning>
<RestorePackages>true</RestorePackages>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="QuikGraph" Version="2.3.0" />
<PackageReference Include="QuikGraph.Graphviz" Version="2.3.1" />
<PackageReference Include="QuikGraph.Serialization" Version="2.3.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Dapper" Version="2.1.28" />
<PackageReference Include="QuikGraph" Version="2.5.0" />
<PackageReference Include="QuikGraph.Graphviz" Version="2.5.0" />
<PackageReference Include="QuikGraph.Serialization" Version="2.5.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.4" />
</ItemGroup>

<ItemGroup>
<None Update="Assets\*.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// See the LICENSE and NOTICES files in the project root for more information.

using System.Collections.Generic;
using System.Linq;

namespace GenerateSecurityGraphs.Models.AuthorizationMetadata
{
Expand Down
45 changes: 7 additions & 38 deletions Utilities/GenerateSecurityGraphs/GenerateSecurityGraphs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.IO.Compression;
using System.Linq;
Expand All @@ -20,6 +19,7 @@
using Dapper;
using GenerateSecurityGraphs.Models.AuthorizationMetadata;
using GenerateSecurityGraphs.Models.Query;
using Microsoft.Data.SqlClient;
using QuikGraph;
using QuikGraph.Graphviz;
using QuikGraph.Graphviz.Dot;
Expand All @@ -46,28 +46,16 @@ internal class Options
[Option('f', "force", Default = false, HelpText = "Create a folder at that path if one doesn't already exist.")]
public bool Force { get; set; }

[Option('d', "database", Default = "EdFi_Security", HelpText = "The name of the database containing the authorization metadata.")]
public string Database { get; set; }

[Option(
's', "server", Default = "(local)", HelpText = "The name of the SQL Server where the authorization metadata database is located.")]
public string Server { get; set; }

[Option(
'u', "user", HelpText =
"The SQL Server username to use for connecting to the authorization metadata database. Leave username and password blank to use integrated security.")]
public string User { get; set; }

[Option(
'p', "password", HelpText =
"The password to use for connecting to the authorization metadata database. Leave username and password blank to use integrated security.")]
public string Password { get; set; }

[Option(
'g', "graphviz", Default = @"C:/Program Files/Graphviz/", HelpText =
"Graphviz installation path.")]
public string GraphvizPath { get; set; }

[Option(
'c', "connectionString", Required = true,
HelpText = "Provide the connection string for the database, including database name, server name, user and password (if necessary)")]
public string ConnectionString { get; set; }

//[HelpOption]
public string GetUsage(string[] args)
{
Expand Down Expand Up @@ -98,25 +86,6 @@ private static async Task Main(string[] args)

if (failedToParse) return;

string connectionString;

if (options.User == null || options.Password == null)
{
connectionString = string.Format(
"Server={0};Database={1};Trusted_Connection=True",
options.Server,
options.Database);
}
else
{
connectionString = string.Format(
"Server={0};Database={1};User ID={2};Password={3}",
options.Server,
options.Database,
options.User,
options.Password);
}

string baseFolderPath;

if (Path.IsPathRooted(options.OutputFolder))
Expand Down Expand Up @@ -180,7 +149,7 @@ private static async Task Main(string[] args)
Console.WriteLine("Generating graphs, please wait ...");

// Load all authorization metadata into a graph and a list of claim sets
var resourceGraph = LoadAuthorizationMetadataGraph(connectionString, out var claimSetNames);
var resourceGraph = LoadAuthorizationMetadataGraph(options.ConnectionString, out var claimSetNames);
var rootNodes = GetRootNodes(resourceGraph);

var assetsSourceFolder = Path.Combine(
Expand Down