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

[Vulnerabilities]Adding new Job for updating v3 Vulnerabilities files. #9740

Merged
merged 16 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
15 changes: 14 additions & 1 deletion NuGetGallery.sln
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
SdkProjects.props = SdkProjects.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGet.Services.GitHub", "src\NuGet.Services.Github\NuGet.Services.GitHub.csproj", "{043645D5-129F-4BA1-BD17-77153294F2BD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuGet.Services.GitHub", "src\NuGet.Services.Github\NuGet.Services.GitHub.csproj", "{043645D5-129F-4BA1-BD17-77153294F2BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHubVulnerabilities2v3", "src\GitHubVulnerabilities2v3\GitHubVulnerabilities2v3.csproj", "{DD9073AF-838E-44E8-91FE-995586E8134A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHubVulnerabilities2v3.Facts", "tests\GitHubVulnerabilities2v3.Facts\GitHubVulnerabilities2v3.Facts.csproj", "{46A2C2EB-B7DC-4FAB-ABE2-A2CE6118585C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -145,6 +149,13 @@ Global
{043645D5-129F-4BA1-BD17-77153294F2BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{043645D5-129F-4BA1-BD17-77153294F2BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{043645D5-129F-4BA1-BD17-77153294F2BD}.Release|Any CPU.Build.0 = Release|Any CPU
{DD9073AF-838E-44E8-91FE-995586E8134A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD9073AF-838E-44E8-91FE-995586E8134A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD9073AF-838E-44E8-91FE-995586E8134A}.Release|Any CPU.Build.0 = Release|Any CPU
{46A2C2EB-B7DC-4FAB-ABE2-A2CE6118585C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{46A2C2EB-B7DC-4FAB-ABE2-A2CE6118585C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46A2C2EB-B7DC-4FAB-ABE2-A2CE6118585C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46A2C2EB-B7DC-4FAB-ABE2-A2CE6118585C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -169,6 +180,8 @@ Global
{E50953CB-209A-484E-951D-A68F5CF3C546} = {39E54EC3-CBAA-453A-BE64-748FE1559A58}
{C0B764D2-D376-439E-A5C4-1AC41B11E9DE} = {2204C510-A559-4ED7-9590-FDC09093575B}
{043645D5-129F-4BA1-BD17-77153294F2BD} = {155100FF-524B-4CAF-93C6-A57478B3DBAD}
{DD9073AF-838E-44E8-91FE-995586E8134A} = {2204C510-A559-4ED7-9590-FDC09093575B}
{46A2C2EB-B7DC-4FAB-ABE2-A2CE6118585C} = {39E54EC3-CBAA-453A-BE64-748FE1559A58}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {064A3BDE-5203-4AD6-A6C9-5CF08301EC8F}
Expand Down
2 changes: 2 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Invoke-BuildStep 'Set version metadata in AssemblyInfo.cs' {
(Join-Path $PSScriptRoot "src\DatabaseMigrationTools\Properties\AssemblyInfo.g.cs"), `
(Join-Path $PSScriptRoot "src\AccountDeleter\Properties\AssemblyInfo.g.cs"), `
(Join-Path $PSScriptRoot "src\GitHubVulnerabilities2Db\Properties\AssemblyInfo.g.cs"), `
(Join-Path $PSScriptRoot "src\GitHubVulnerabilities2v3\Properties\AssemblyInfo.g.cs"), `
(Join-Path $PSScriptRoot "src\GalleryTools\Properties\AssemblyInfo.g.cs"), `
(Join-Path $PSScriptRoot "src\VerifyMicrosoftPackage\Properties\AssemblyInfo.g.cs")

Expand Down Expand Up @@ -119,6 +120,7 @@ Invoke-BuildStep 'Creating artifacts' { `
New-Package (Join-Path $PSScriptRoot "src\DatabaseMigrationTools\DatabaseMigration.Validation.nuspec") -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch
New-Package (Join-Path $PSScriptRoot "src\AccountDeleter\Gallery.AccountDeleter.nuspec") -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch
New-Package (Join-Path $PSScriptRoot "src\GitHubVulnerabilities2Db\GitHubVulnerabilities2Db.nuspec") -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch
New-Package (Join-Path $PSScriptRoot "src\GitHubVulnerabilities2v3\GitHubVulnerabilities2v3.nuspec") -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch
New-Package (Join-Path $PSScriptRoot "src\GalleryTools\Gallery.GalleryTools.nuspec") -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch
New-Package (Join-Path $PSScriptRoot "src\VerifyGitHubVulnerabilities\VerifyGitHubVulnerabilities.nuspec") -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch

Expand Down
6 changes: 6 additions & 0 deletions src/GitHubVulnerabilities2v3/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering if we really need NETFramework 4.7.2 for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was generated (I think?) as part of the project template? I am not 100% sure if we need it or what it does. Does anybody with a bit more knowledge here know if this can safely be removed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RiadGahlouz are you asking if .NET (Core) would suffice here instead of .NET Framework?

Regarding the need for this file, I believe we have it for all of our entry points (web apps, jobs), but not all of our libraries. I'd say just leave it and be consistent with everything else.

</startup>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using NuGet.Services.GitHub.Configuration;

namespace GitHubVulnerabilities2v3.Configuration
{
public class GitHubVulnerabilities2v3Configuration : GraphQLQueryConfiguration
{
/// <summary>
/// The storage connection to use to save the job's output.
/// </summary>
public string StorageConnectionString { get; set; }

/// <summary>
/// The storage container to save the job's output in.
/// </summary>
public string V3VulnerabilityContainerName { get; set; } = "v3-vulnerabilities";

/// <summary>
/// Service Index Root
/// </summary>
public string V3BaseUrl { get; set; } = "https://api.nuget.org/";

/// <summary>
/// The name of the blob to save the job's advisories cursor in.
/// </summary>
public string AdvisoryCursorBlobName { get; set; } = "cursor.json";

/// <summary>
/// The names of the generated files.
/// </summary>
public string IndexFileName { get; set; } = "index.json";
public string BaseFileName { get; set; } = "vulnerability.base.json";
public string UpdateFileName { get; set; } = "vulnerability.update.json";

/// <summary>
/// Other Runtime Configurations
/// </summary>
public int DaysBeforeBaseStale { get; set; } = 30;

/// <summary>
/// Cache control headers.
/// </summary>
public string IndexCacheControlHeader { get; set; } = "max-age=259200, must-revalidate";
public string BaseCacheControlHeader { get; set; } = "max-age=604800, must-revalidate";
public string UpdateCacheControlHeader { get; set; } = "max-age=604800, must-revalidate";
}
}
19 changes: 19 additions & 0 deletions src/GitHubVulnerabilities2v3/Entities/Advisory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Newtonsoft.Json;

namespace GitHubVulnerabilities2v3.Entities
{
public class Advisory
{
[JsonProperty(PropertyName = "url")]
public string Url { get; set; }

[JsonProperty(PropertyName = "severity")]
public int Severity { get; set; }

[JsonProperty(PropertyName = "versions")]
public string Versions { get; set; }
}
}
23 changes: 23 additions & 0 deletions src/GitHubVulnerabilities2v3/Entities/IndexEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Newtonsoft.Json;
using System;

namespace GitHubVulnerabilities2v3.Entities
{
public class IndexEntry
{
[JsonProperty(PropertyName = "@name")]
public string Name { get; set; }

[JsonProperty(PropertyName = "@id")]
public string Id { get; set; }

[JsonProperty(PropertyName = "@updated")]
public DateTime Updated { get; set; }

[JsonProperty(PropertyName = "comment")]
public string Comment { get; set; }
}
}
Loading