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

Update cgmanifest to align with the JSON schema #2969

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

jeffhandley
Copy link
Contributor

With dotnet/machinelearning#7283, we realized that the cgmanifest.json file was not aligned with the JSON schema. It is using Title case property names but it should be using camelCase property names. See this comment for more detail: dotnet/machinelearning#7283 (comment)

I'm following up by updating each CG manifest in the dotnet org where we had the same issue, and this match was found at https://github.com/dotnet/dotnet/blob/main/src/source-build-externals/src/azure-activedirectory-identitymodel-extensions-for-dotnet/build/cgmanifest.json.

Here's the console app I used to confirm the existing manifest isn't valid against its schema, and the updated one in this PR is valid:

using System;
using System.Net.Http;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using Json.Schema; // Requires package JsonSchema.Net

HttpClient httpClient = new();

string schemaUrl = "https://json.schemastore.org/component-detection-manifest.json";
HttpResponseMessage schemaResponse = await httpClient.GetAsync(schemaUrl);
schemaResponse.EnsureSuccessStatusCode();
string schemaJson = (await schemaResponse.Content.ReadAsStringAsync()).Replace("/draft-04/", "/draft-06/");
JsonSchema schema = JsonSchema.FromText(schemaJson);

string[] manifestUrls = [
    "https://raw.githubusercontent.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/refs/heads/dev/build/cgmanifest.json",
    "https://raw.githubusercontent.com/jeffhandley/azure-activedirectory-identitymodel-extensions-for-dotnet/refs/heads/jeffhandley/cgmanifest/build/cgmanifest.json"
];

foreach (var manifestUrl in manifestUrls)
{
    HttpResponseMessage manifestResponse = await httpClient.GetAsync(manifestUrl);
    manifestResponse.EnsureSuccessStatusCode();
    string manifestJson = await manifestResponse.Content.ReadAsStringAsync();

    JsonNode manifest = JsonNode.Parse(manifestJson);

    var result = schema.Evaluate(manifest);
    Console.WriteLine(manifestUrl);
    Console.WriteLine($"Valid: {result.IsValid}");
    Console.WriteLine();
}

Here's the output:

https://raw.githubusercontent.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/refs/heads/dev/build/cgmanifest.json
Valid: False

https://raw.githubusercontent.com/jeffhandley/azure-activedirectory-identitymodel-extensions-for-dotnet/refs/heads/jeffhandley/cgmanifest/build/cgmanifest.json
Valid: True

@jeffhandley jeffhandley requested a review from a team as a code owner November 1, 2024 18:35
@jeffhandley
Copy link
Contributor Author

FYI after merging dotnet/runtime#109453 with the same change, I dug in to understand why/how the component governance integration was still working despite the JSON document not adhering to the schema. I was able to confirm that it was working before, and it's still working after this change. The reason it worked is that the component detection that processes these files has the JSON deserialization set up where it is recognizing either TitleCase or properCase property names.

So while it was working before, we're now adhering to the schema correctly and we won't get tripped up if the component detection ever applies stricter validation of the documents.

@brentschmaltz brentschmaltz merged commit 73e2c18 into AzureAD:dev Nov 7, 2024
4 of 5 checks passed
@pmaytak pmaytak added this to the 8.2.1 milestone Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants