Skip to content

Commit

Permalink
[Feat] Add Advanced Security Properties to Repository Get/Update (#2865)
Browse files Browse the repository at this point in the history
* add SecurityAndAnalysis to repository get/update

* add repository advanced security

* cleanup

---------

Co-authored-by: Dirty Gooback <19241000+dirtygooback@users.noreply.github.com>
Co-authored-by: Nick Floyd <139819+nickfloyd@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 24, 2024
1 parent bdc1694 commit b208057
Show file tree
Hide file tree
Showing 5 changed files with 379 additions and 4 deletions.
12 changes: 12 additions & 0 deletions Octokit/Models/Common/Status.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Octokit.Internal;

namespace Octokit
{
public enum Status
{
[Parameter(Value = "enabled")]
Enabled,
[Parameter(Value = "disabled")]
Disabled
}
}
3 changes: 3 additions & 0 deletions Octokit/Models/Request/RepositoryUpdate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Octokit.Internal;
using Octokit.Models.Response;
using System;
using System.Diagnostics;

Expand Down Expand Up @@ -133,6 +134,8 @@ public RepositoryUpdate() { }
/// </summary>
public bool? HasDiscussions { get; set; }

public SecurityAndAnalysisRequest SecurityAndAnalysis { get; set; }

internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this);
}
}
184 changes: 184 additions & 0 deletions Octokit/Models/Request/SecurityAndAnalysisRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
using Octokit.Internal;
using System.Diagnostics;


namespace Octokit
{
/// <summary>
/// The security and analysis features that are enabled or disabled for the repository
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class SecurityAndAnalysisRequest
{
public SecurityAndAnalysisRequest()
{ }

public SecurityAndAnalysisRequest(AdvancedSecurityRequest advancedSecurity, DependabotSecurityUpdatesRequest dependabotSecurityUpdates,
SecretScanningRequest secretScanning, SecretScanningPushProtectionRequest secretScanningPushProtection,
SecretScanningValidityChecksRequest secretScanningValidityChecks)
{
this.AdvancedSecurity = advancedSecurity;
this.DependabotSecurityUpdates = dependabotSecurityUpdates;
this.SecretScanning = secretScanning;
this.SecretScanningPushProtection = secretScanningPushProtection;
this.SecretScanningValidityChecks = secretScanningValidityChecks;
}


public AdvancedSecurityRequest AdvancedSecurity { get; set; }
public DependabotSecurityUpdatesRequest DependabotSecurityUpdates { get; set; }
public SecretScanningRequest SecretScanning { get; set; }
public SecretScanningPushProtectionRequest SecretScanningPushProtection { get; set; }
public SecretScanningValidityChecksRequest SecretScanningValidityChecks { get; set; }


internal string DebuggerDisplay
{
get
{
return new SimpleJsonSerializer().Serialize(this);
}
}
}


/// <summary>
/// Use the status property to enable or disable GitHub Advanced Security for this repository
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class AdvancedSecurityRequest
{
public AdvancedSecurityRequest()
{ }

public AdvancedSecurityRequest(Status? status)
{
this.Status = status;
}

/// <summary>
/// Can be enabled, disabled, or null
/// </summary>
public Status? Status { get; set; }

internal string DebuggerDisplay
{
get
{
return new SimpleJsonSerializer().Serialize(this);
}
}
}

/// <summary>
/// Use the status property to enable or disable Dependabot security updates for this repository
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class DependabotSecurityUpdatesRequest
{
public DependabotSecurityUpdatesRequest()
{ }

public DependabotSecurityUpdatesRequest(Status? status)
{
this.Status = status;
}

/// <summary>
/// Can be enabled, disabled, or null
/// </summary>
public Status? Status { get; set; }

internal string DebuggerDisplay
{
get
{
return new SimpleJsonSerializer().Serialize(this);
}
}
}

/// <summary>
/// Use the status property to enable or disable secret scanning for this repository
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class SecretScanningRequest
{
public SecretScanningRequest()
{ }

public SecretScanningRequest(Status? status)
{
this.Status = status;
}

/// <summary>
/// Can be enabled, disabled, or null
/// </summary>
public Status? Status { get; set; }

internal string DebuggerDisplay
{
get
{
return new SimpleJsonSerializer().Serialize(this);
}
}
}

/// <summary>
/// Use the status property to enable or disable secret scanning push protection for this repository
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class SecretScanningPushProtectionRequest
{
public SecretScanningPushProtectionRequest()
{ }

public SecretScanningPushProtectionRequest(Status? status)
{
this.Status = status;
}

/// <summary>
/// Can be enabled, disabled, or null
/// </summary>
public Status? Status { get; set; }

internal string DebuggerDisplay
{
get
{
return new SimpleJsonSerializer().Serialize(this);
}
}
}

/// <summary>
/// Use the status property to enable or disable secret scanning validity checks for this repository
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class SecretScanningValidityChecksRequest
{
public SecretScanningValidityChecksRequest()
{ }

public SecretScanningValidityChecksRequest(Status? status)
{
this.Status = status;
}

/// <summary>
/// Can be enabled, disabled, or null
/// </summary>
public Status? Status { get; set; }

internal string DebuggerDisplay
{
get
{
return new SimpleJsonSerializer().Serialize(this);
}
}
}
}
7 changes: 3 additions & 4 deletions Octokit/Models/Response/Repository.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
Expand All @@ -17,7 +16,7 @@ public Repository(long id)
Id = id;
}

public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, string archiveUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasDiscussions, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge, RepositoryVisibility visibility, IEnumerable<string> topics, bool? allowAutoMerge, bool? allowUpdateBranch, bool? webCommitSignoffRequired, IReadOnlyDictionary<string, object> customProperties)
public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, string archiveUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasDiscussions, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge, RepositoryVisibility visibility, IEnumerable<string> topics, bool? allowAutoMerge, bool? allowUpdateBranch, bool? webCommitSignoffRequired, SecurityAndAnalysis securityAndAnalysis)
{
Url = url;
HtmlUrl = htmlUrl;
Expand Down Expand Up @@ -69,7 +68,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st
AllowAutoMerge = allowAutoMerge;
AllowUpdateBranch = allowUpdateBranch;
WebCommitSignoffRequired = webCommitSignoffRequired;
CustomProperties = customProperties;
SecurityAndAnalysis = securityAndAnalysis;
}

public string Url { get; private set; }
Expand Down Expand Up @@ -171,7 +170,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st

public bool? WebCommitSignoffRequired { get; private set; }

public IReadOnlyDictionary<string, object> CustomProperties { get; private set; }
public SecurityAndAnalysis SecurityAndAnalysis { get; private set;}

internal string DebuggerDisplay
{
Expand Down
Loading

0 comments on commit b208057

Please sign in to comment.