Skip to content

Commit

Permalink
feat: secret scanning validity checks, secret scanning non provider p…
Browse files Browse the repository at this point in the history
…atterns (#97)

* New updates to generated code

* New updates to generated code

---------

Co-authored-by: Octokit Bot <[email protected]>
  • Loading branch information
octokitbot and Octokit Bot authored Jul 15, 2024
1 parent 93c060d commit 668e0f0
Show file tree
Hide file tree
Showing 15 changed files with 392 additions and 14 deletions.
3 changes: 1 addition & 2 deletions cli/Authentication/PersonalAccessToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ namespace cli.Authentication;
/*
For Personal Access Token Auth you'll need the following environment variable. For more information see the [GitHub docs](https://docs.github.com/en/rest/orgs/personal-access-tokens).
`GITHUB_TOKEN`
`GITHUB_TOKEN`
- Description: The personal access token for the user
- Location: Found under User > Settings > Developer Settings > [Token Type]
*/

public class PersonalAccessToken
Expand Down
2 changes: 1 addition & 1 deletion cli/keys/NewKey.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Currently for this CLI (or any other) to use GitHubs App Installation Auth you need a private key that can be used to create a Json Web Token.

You should be able to follow the steps [here](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/managing-private-keys-for-github-apps) to generate a private key for the cli to use during app installation auth. `.gitignore` will ignore any .pem files that are in this directory to prevent anyone from accidentally commiting a private key.
You should be able to follow the steps [here](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/managing-private-keys-for-github-apps) to generate a private key for the cli to use during app installation auth. `.gitignore` will ignore any .pem files that are in this directory to prevent anyone from accidentally commiting a private key.
4 changes: 4 additions & 0 deletions src/GitHub/Models/CodeSecurityConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class CodeSecurityConfiguration : IAdditionalDataHolder, IParsable
public CodeSecurityConfiguration_secret_scanning? SecretScanning { get; set; }
/// <summary>The enablement status of secret scanning push protection</summary>
public CodeSecurityConfiguration_secret_scanning_push_protection? SecretScanningPushProtection { get; set; }
/// <summary>The enablement status of secret scanning validity checks</summary>
public CodeSecurityConfiguration_secret_scanning_validity_checks? SecretScanningValidityChecks { get; set; }
/// <summary>The type of the code security configuration.</summary>
public CodeSecurityConfiguration_target_type? TargetType { get; set; }
/// <summary>The updated_at property</summary>
Expand Down Expand Up @@ -106,6 +108,7 @@ public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{"private_vulnerability_reporting", n => { PrivateVulnerabilityReporting = n.GetEnumValue<CodeSecurityConfiguration_private_vulnerability_reporting>(); } },
{"secret_scanning", n => { SecretScanning = n.GetEnumValue<CodeSecurityConfiguration_secret_scanning>(); } },
{"secret_scanning_push_protection", n => { SecretScanningPushProtection = n.GetEnumValue<CodeSecurityConfiguration_secret_scanning_push_protection>(); } },
{"secret_scanning_validity_checks", n => { SecretScanningValidityChecks = n.GetEnumValue<CodeSecurityConfiguration_secret_scanning_validity_checks>(); } },
{"target_type", n => { TargetType = n.GetEnumValue<CodeSecurityConfiguration_target_type>(); } },
{"updated_at", n => { UpdatedAt = n.GetDateTimeOffsetValue(); } },
{"url", n => { Url = n.GetStringValue(); } },
Expand All @@ -131,6 +134,7 @@ public virtual void Serialize(ISerializationWriter writer)
writer.WriteEnumValue<CodeSecurityConfiguration_private_vulnerability_reporting>("private_vulnerability_reporting", PrivateVulnerabilityReporting);
writer.WriteEnumValue<CodeSecurityConfiguration_secret_scanning>("secret_scanning", SecretScanning);
writer.WriteEnumValue<CodeSecurityConfiguration_secret_scanning_push_protection>("secret_scanning_push_protection", SecretScanningPushProtection);
writer.WriteEnumValue<CodeSecurityConfiguration_secret_scanning_validity_checks>("secret_scanning_validity_checks", SecretScanningValidityChecks);
writer.WriteEnumValue<CodeSecurityConfiguration_target_type>("target_type", TargetType);
writer.WriteDateTimeOffsetValue("updated_at", UpdatedAt);
writer.WriteStringValue("url", Url);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// <auto-generated/>
using System.Runtime.Serialization;
using System;
namespace GitHub.Models {
/// <summary>The enablement status of secret scanning validity checks</summary>
public enum CodeSecurityConfiguration_secret_scanning_validity_checks
{
[EnumMember(Value = "enabled")]
#pragma warning disable CS1591
Enabled,
#pragma warning restore CS1591
[EnumMember(Value = "disabled")]
#pragma warning disable CS1591
Disabled,
#pragma warning restore CS1591
[EnumMember(Value = "not_set")]
#pragma warning disable CS1591
Not_set,
#pragma warning restore CS1591
}
}
168 changes: 158 additions & 10 deletions src/GitHub/Models/Commit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ public class Commit : IAdditionalDataHolder, IParsable
{
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
public IDictionary<string, object> AdditionalData { get; set; }
/// <summary>A GitHub user.</summary>
/// <summary>The author property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public NullableSimpleUser? Author { get; set; }
public Commit_author? Author { get; set; }
#nullable restore
#else
public NullableSimpleUser Author { get; set; }
public Commit_author Author { get; set; }
#endif
/// <summary>The comments_url property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
Expand All @@ -36,13 +36,13 @@ public class Commit : IAdditionalDataHolder, IParsable
#else
public Commit_commit CommitProp { get; set; }
#endif
/// <summary>A GitHub user.</summary>
/// <summary>The committer property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public NullableSimpleUser? Committer { get; set; }
public Commit_committer? Committer { get; set; }
#nullable restore
#else
public NullableSimpleUser Committer { get; set; }
public Commit_committer Committer { get; set; }
#endif
/// <summary>The files property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
Expand Down Expand Up @@ -125,10 +125,10 @@ public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
{
{"author", n => { Author = n.GetObjectValue<NullableSimpleUser>(NullableSimpleUser.CreateFromDiscriminatorValue); } },
{"author", n => { Author = n.GetObjectValue<Commit_author>(Commit_author.CreateFromDiscriminatorValue); } },
{"comments_url", n => { CommentsUrl = n.GetStringValue(); } },
{"commit", n => { CommitProp = n.GetObjectValue<Commit_commit>(Commit_commit.CreateFromDiscriminatorValue); } },
{"committer", n => { Committer = n.GetObjectValue<NullableSimpleUser>(NullableSimpleUser.CreateFromDiscriminatorValue); } },
{"committer", n => { Committer = n.GetObjectValue<Commit_committer>(Commit_committer.CreateFromDiscriminatorValue); } },
{"files", n => { Files = n.GetCollectionOfObjectValues<DiffEntry>(DiffEntry.CreateFromDiscriminatorValue)?.ToList(); } },
{"html_url", n => { HtmlUrl = n.GetStringValue(); } },
{"node_id", n => { NodeId = n.GetStringValue(); } },
Expand All @@ -145,10 +145,10 @@ public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
public virtual void Serialize(ISerializationWriter writer)
{
_ = writer ?? throw new ArgumentNullException(nameof(writer));
writer.WriteObjectValue<NullableSimpleUser>("author", Author);
writer.WriteObjectValue<Commit_author>("author", Author);
writer.WriteStringValue("comments_url", CommentsUrl);
writer.WriteObjectValue<Commit_commit>("commit", CommitProp);
writer.WriteObjectValue<NullableSimpleUser>("committer", Committer);
writer.WriteObjectValue<Commit_committer>("committer", Committer);
writer.WriteCollectionOfObjectValues<DiffEntry>("files", Files);
writer.WriteStringValue("html_url", HtmlUrl);
writer.WriteStringValue("node_id", NodeId);
Expand All @@ -158,5 +158,153 @@ public virtual void Serialize(ISerializationWriter writer)
writer.WriteStringValue("url", Url);
writer.WriteAdditionalData(AdditionalData);
}
/// <summary>
/// Composed type wrapper for classes <see cref="EmptyObject"/>, <see cref="SimpleUser"/>
/// </summary>
public class Commit_author : IComposedTypeWrapper, IParsable
{
/// <summary>Composed type representation for type <see cref="GitHub.Models.EmptyObject"/></summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public GitHub.Models.EmptyObject? EmptyObject { get; set; }
#nullable restore
#else
public GitHub.Models.EmptyObject EmptyObject { get; set; }
#endif
/// <summary>Composed type representation for type <see cref="GitHub.Models.SimpleUser"/></summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public GitHub.Models.SimpleUser? SimpleUser { get; set; }
#nullable restore
#else
public GitHub.Models.SimpleUser SimpleUser { get; set; }
#endif
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="Commit_author"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
public static Commit_author CreateFromDiscriminatorValue(IParseNode parseNode)
{
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
var mappingValue = parseNode.GetChildNode("")?.GetStringValue();
var result = new Commit_author();
if("empty-object".Equals(mappingValue, StringComparison.OrdinalIgnoreCase))
{
result.EmptyObject = new GitHub.Models.EmptyObject();
}
else if("simple-user".Equals(mappingValue, StringComparison.OrdinalIgnoreCase))
{
result.SimpleUser = new GitHub.Models.SimpleUser();
}
return result;
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
if(EmptyObject != null)
{
return EmptyObject.GetFieldDeserializers();
}
else if(SimpleUser != null)
{
return SimpleUser.GetFieldDeserializers();
}
return new Dictionary<string, Action<IParseNode>>();
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
public virtual void Serialize(ISerializationWriter writer)
{
_ = writer ?? throw new ArgumentNullException(nameof(writer));
if(EmptyObject != null)
{
writer.WriteObjectValue<GitHub.Models.EmptyObject>(null, EmptyObject);
}
else if(SimpleUser != null)
{
writer.WriteObjectValue<GitHub.Models.SimpleUser>(null, SimpleUser);
}
}
}
/// <summary>
/// Composed type wrapper for classes <see cref="EmptyObject"/>, <see cref="SimpleUser"/>
/// </summary>
public class Commit_committer : IComposedTypeWrapper, IParsable
{
/// <summary>Composed type representation for type <see cref="GitHub.Models.EmptyObject"/></summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public GitHub.Models.EmptyObject? EmptyObject { get; set; }
#nullable restore
#else
public GitHub.Models.EmptyObject EmptyObject { get; set; }
#endif
/// <summary>Composed type representation for type <see cref="GitHub.Models.SimpleUser"/></summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public GitHub.Models.SimpleUser? SimpleUser { get; set; }
#nullable restore
#else
public GitHub.Models.SimpleUser SimpleUser { get; set; }
#endif
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="Commit_committer"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
public static Commit_committer CreateFromDiscriminatorValue(IParseNode parseNode)
{
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
var mappingValue = parseNode.GetChildNode("")?.GetStringValue();
var result = new Commit_committer();
if("empty-object".Equals(mappingValue, StringComparison.OrdinalIgnoreCase))
{
result.EmptyObject = new GitHub.Models.EmptyObject();
}
else if("simple-user".Equals(mappingValue, StringComparison.OrdinalIgnoreCase))
{
result.SimpleUser = new GitHub.Models.SimpleUser();
}
return result;
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
if(EmptyObject != null)
{
return EmptyObject.GetFieldDeserializers();
}
else if(SimpleUser != null)
{
return SimpleUser.GetFieldDeserializers();
}
return new Dictionary<string, Action<IParseNode>>();
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
public virtual void Serialize(ISerializationWriter writer)
{
_ = writer ?? throw new ArgumentNullException(nameof(writer));
if(EmptyObject != null)
{
writer.WriteObjectValue<GitHub.Models.EmptyObject>(null, EmptyObject);
}
else if(SimpleUser != null)
{
writer.WriteObjectValue<GitHub.Models.SimpleUser>(null, SimpleUser);
}
}
}
}
}
10 changes: 10 additions & 0 deletions src/GitHub/Models/SecurityAndAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ public class SecurityAndAnalysis : IAdditionalDataHolder, IParsable
#nullable restore
#else
public SecurityAndAnalysis_secret_scanning SecretScanning { get; set; }
#endif
/// <summary>The secret_scanning_non_provider_patterns property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public SecurityAndAnalysis_secret_scanning_non_provider_patterns? SecretScanningNonProviderPatterns { get; set; }
#nullable restore
#else
public SecurityAndAnalysis_secret_scanning_non_provider_patterns SecretScanningNonProviderPatterns { get; set; }
#endif
/// <summary>The secret_scanning_push_protection property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
Expand Down Expand Up @@ -71,6 +79,7 @@ public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{"advanced_security", n => { AdvancedSecurity = n.GetObjectValue<SecurityAndAnalysis_advanced_security>(SecurityAndAnalysis_advanced_security.CreateFromDiscriminatorValue); } },
{"dependabot_security_updates", n => { DependabotSecurityUpdates = n.GetObjectValue<SecurityAndAnalysis_dependabot_security_updates>(SecurityAndAnalysis_dependabot_security_updates.CreateFromDiscriminatorValue); } },
{"secret_scanning", n => { SecretScanning = n.GetObjectValue<SecurityAndAnalysis_secret_scanning>(SecurityAndAnalysis_secret_scanning.CreateFromDiscriminatorValue); } },
{"secret_scanning_non_provider_patterns", n => { SecretScanningNonProviderPatterns = n.GetObjectValue<SecurityAndAnalysis_secret_scanning_non_provider_patterns>(SecurityAndAnalysis_secret_scanning_non_provider_patterns.CreateFromDiscriminatorValue); } },
{"secret_scanning_push_protection", n => { SecretScanningPushProtection = n.GetObjectValue<SecurityAndAnalysis_secret_scanning_push_protection>(SecurityAndAnalysis_secret_scanning_push_protection.CreateFromDiscriminatorValue); } },
};
}
Expand All @@ -84,6 +93,7 @@ public virtual void Serialize(ISerializationWriter writer)
writer.WriteObjectValue<SecurityAndAnalysis_advanced_security>("advanced_security", AdvancedSecurity);
writer.WriteObjectValue<SecurityAndAnalysis_dependabot_security_updates>("dependabot_security_updates", DependabotSecurityUpdates);
writer.WriteObjectValue<SecurityAndAnalysis_secret_scanning>("secret_scanning", SecretScanning);
writer.WriteObjectValue<SecurityAndAnalysis_secret_scanning_non_provider_patterns>("secret_scanning_non_provider_patterns", SecretScanningNonProviderPatterns);
writer.WriteObjectValue<SecurityAndAnalysis_secret_scanning_push_protection>("secret_scanning_push_protection", SecretScanningPushProtection);
writer.WriteAdditionalData(AdditionalData);
}
Expand Down
Loading

0 comments on commit 668e0f0

Please sign in to comment.