Skip to content

Commit

Permalink
Merge branch 'main' into feature/4615/rohitkrsoni
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitkrsoni committed May 20, 2024
2 parents 91d24a0 + 43f12f4 commit 17b08be
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 25 deletions.
32 changes: 16 additions & 16 deletions .github/policies/resourceManagement.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
id:
id:
name: GitOps.PullRequestIssueManagement
description: GitOps.PullRequestIssueManagement primitive
owner:
owner:
resource: repository
disabled: false
where:
where:
configuration:
resourceManagementConfiguration:
scheduledSearches:
- description:
- description:
frequencies:
- hourly:
hour: 6
filters:
- isIssue
- isOpen
- hasLabel:
label: 'Needs: Author Feedback'
label: 'status:waiting-for-author-feedback'
- hasLabel:
label: 'Status: No Recent Activity'
- noActivitySince:
days: 3
actions:
- closeIssue
- description:
- description:
frequencies:
- hourly:
hour: 6
filters:
- isIssue
- isOpen
- hasLabel:
label: 'Needs: Author Feedback'
label: 'status:waiting-for-author-feedback'
- noActivitySince:
days: 4
- isNotLabeledWith:
Expand All @@ -41,7 +41,7 @@ configuration:
label: 'Status: No Recent Activity'
- addReply:
reply: This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
- description:
- description:
frequencies:
- hourly:
hour: 6
Expand All @@ -64,14 +64,14 @@ configuration:
- isActivitySender:
issueAuthor: True
- hasLabel:
label: 'Needs: Author Feedback'
label: 'status:waiting-for-author-feedback'
- isOpen
then:
- addLabel:
label: 'Needs: Attention :wave:'
- removeLabel:
label: 'Needs: Author Feedback'
description:
label: 'status:waiting-for-author-feedback'
description:
- if:
- payloadType: Issues
- not:
Expand All @@ -82,20 +82,20 @@ configuration:
then:
- removeLabel:
label: 'Status: No Recent Activity'
description:
description:
- if:
- payloadType: Issue_Comment
- hasLabel:
label: 'Status: No Recent Activity'
then:
- removeLabel:
label: 'Status: No Recent Activity'
description:
description:
- if:
- payloadType: Pull_Request
then:
- inPrLabel:
label: WIP
description:
onFailure:
onSuccess:
description:
onFailure:
onSuccess:
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support for multipart form data request body in PHP. [#3029](https://github.com/microsoft/kiota/issues/3029)
- Added uri-form encoded serialization for PHP. [#2074](https://github.com/microsoft/kiota/issues/2074)
- Added information message with base URL in the CLI experience. [#4635](https://github.com/microsoft/kiota/issues/4635)
- Added optional parameter --disable-ssl-validation for generate, show, and download commands. [#4176](https://github.com/microsoft/kiota/issues/4176)

### Changed

Expand Down
8 changes: 4 additions & 4 deletions it/python/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-i https://pypi.org/simple

astroid==3.2.1 ; python_full_version >= '3.7.2'
astroid==3.2.2 ; python_full_version >= '3.7.2'

certifi==2024.2.2 ; python_version >= '3.6'

Expand Down Expand Up @@ -40,11 +40,11 @@ platformdirs==4.2.2 ; python_version >= '3.7'

pluggy==1.5.0 ; python_version >= '3.7'

pylint==3.2.0
pylint==3.2.2

pytest==8.2.0
pytest==8.2.1

pytest-asyncio==0.23.6
pytest-asyncio==0.23.7

requests==2.31.0 ; python_version >= '3.7'

Expand Down
7 changes: 6 additions & 1 deletion src/Kiota.Builder/Configuration/DownloadConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ public bool CleanOutput
{
get; set;
}
public bool DisableSSLValidation
{
get; set;
}

public object Clone()
{
return new DownloadConfiguration
{
OutputPath = OutputPath,
CleanOutput = CleanOutput,
ClearCache = ClearCache
ClearCache = ClearCache,
DisableSSLValidation = DisableSSLValidation,
};
}
}
6 changes: 6 additions & 0 deletions src/Kiota.Builder/Configuration/GenerationConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public object Clone()
Operation = Operation,
PatternsOverride = new(PatternsOverride ?? Enumerable.Empty<string>(), StringComparer.OrdinalIgnoreCase),
PluginTypes = new(PluginTypes ?? Enumerable.Empty<PluginType>()),
DisableSSLValidation = DisableSSLValidation,
};
}
private static readonly StringIEnumerableDeepComparer comparer = new();
Expand Down Expand Up @@ -200,6 +201,11 @@ private string NormalizeDescriptionLocation(string targetDirectory)
return OpenAPIFilePath;
}
public bool IsPluginConfiguration => PluginTypes.Count != 0;

public bool DisableSSLValidation
{
get; set;
}
}
#pragma warning restore CA1056
#pragma warning restore CA2227
9 changes: 9 additions & 0 deletions src/Kiota.Builder/Lock/KiotaLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ public bool IncludeAdditionalData
{
get; set;
}
/// <summary>
/// Whether SSL Validation was disabled for this client.
/// </summary>
public bool DisableSSLValidation
{
get; set;
}
#pragma warning disable CA2227
/// <summary>
/// The serializers used for this client.
Expand Down Expand Up @@ -108,6 +115,7 @@ public void UpdateGenerationConfigurationFromLock(GenerationConfiguration config
config.ExcludePatterns = ExcludePatterns;
config.OpenAPIFilePath = DescriptionLocation;
config.DisabledValidationRules = DisabledValidationRules;
config.DisableSSLValidation = DisableSSLValidation;
}
/// <summary>
/// Initializes a new instance of the <see cref="KiotaLock"/> class.
Expand Down Expand Up @@ -135,5 +143,6 @@ public KiotaLock(GenerationConfiguration config)
ExcludePatterns = config.ExcludePatterns;
DescriptionLocation = config.OpenAPIFilePath;
DisabledValidationRules = config.DisabledValidationRules;
DisableSSLValidation = config.DisableSSLValidation;
}
}
1 change: 1 addition & 0 deletions src/Kiota.Builder/Lock/KiotaLockComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public int GetHashCode([DisallowNull] KiotaLock obj)
{
if (obj == null) return 0;
return
obj.DisableSSLValidation.GetHashCode() * 59 +
_stringIEnumerableDeepComparer.GetHashCode(obj.DisabledValidationRules?.Order(StringComparer.OrdinalIgnoreCase) ?? Enumerable.Empty<string>()) * 53 +
obj.KiotaVersion.GetHashCode(StringComparison.OrdinalIgnoreCase) * 47 +
obj.LockFileVersion.GetHashCode(StringComparison.OrdinalIgnoreCase) * 43 +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@
"**/generate",
"**/repos/**/topics"
],
"disabledValidationRules": []
}
"disabledValidationRules": [],
"disableSSLValidation": false
}
26 changes: 25 additions & 1 deletion src/kiota/Handlers/BaseKiotaCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ protected static void DefaultSerializersAndDeserializers(GenerationConfiguration
Logger = logger,
FileName = "pat-api.github.com"
};
internal static readonly HttpClient httpClient = new();

private HttpClient? _httpClient;
protected HttpClient httpClient
{
get
{
_httpClient ??= GetHttpClient();
return _httpClient;
}
}
public required Option<LogLevel> LogLevelOption
{
get; init;
Expand All @@ -52,6 +61,21 @@ protected KiotaConfiguration Configuration
configObject.BindConfiguration(configuration);
return configObject;
});

protected HttpClient GetHttpClient()
{
var httpClientHandler = new HttpClientHandler();
if (Configuration.Generation.DisableSSLValidation)
httpClientHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;

var httpClient = new HttpClient(httpClientHandler);

disposables.Add(httpClientHandler);
disposables.Add(httpClient);

return httpClient;
}

private const string GitHubScope = "repo";
private Func<CancellationToken, Task<bool>> GetIsGitHubDeviceSignedInCallback(ILogger logger) => (cancellationToken) =>
{
Expand Down
6 changes: 6 additions & 0 deletions src/kiota/Handlers/KiotaDownloadCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,22 @@ public required Option<bool> CleanOutputOption
{
get; init;
}
public required Option<bool> DisableSSLValidationOption
{
get; init;
}
public override async Task<int> InvokeAsync(InvocationContext context)
{
string searchTerm = context.ParseResult.GetValueForArgument(SearchTermArgument);
string version = context.ParseResult.GetValueForOption(VersionOption) ?? string.Empty;
string outputPath = context.ParseResult.GetValueForOption(OutputPathOption) ?? string.Empty;
bool cleanOutput = context.ParseResult.GetValueForOption(CleanOutputOption);
bool clearCache = context.ParseResult.GetValueForOption(ClearCacheOption);
bool disableSSLValidation = context.ParseResult.GetValueForOption(DisableSSLValidationOption);
CancellationToken cancellationToken = context.BindingContext.GetService(typeof(CancellationToken)) is CancellationToken token ? token : CancellationToken.None;

Configuration.Download.ClearCache = clearCache;
Configuration.Download.DisableSSLValidation = disableSSLValidation;
Configuration.Download.CleanOutput = cleanOutput;
Configuration.Download.OutputPath = NormalizeSlashesInPath(outputPath);

Expand Down
6 changes: 6 additions & 0 deletions src/kiota/Handlers/KiotaGenerateCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public override async Task<int> InvokeAsync(InvocationContext context)
bool backingStore = context.ParseResult.GetValueForOption(BackingStoreOption);
bool excludeBackwardCompatible = context.ParseResult.GetValueForOption(ExcludeBackwardCompatibleOption);
bool clearCache = context.ParseResult.GetValueForOption(ClearCacheOption);
bool disableSSLValidation = context.ParseResult.GetValueForOption(DisableSSLValidationOption);
bool includeAdditionalData = context.ParseResult.GetValueForOption(AdditionalDataOption);
string className = context.ParseResult.GetValueForOption(ClassOption) ?? string.Empty;
string namespaceName = context.ParseResult.GetValueForOption(NamespaceOption) ?? string.Empty;
Expand Down Expand Up @@ -112,6 +113,7 @@ public override async Task<int> InvokeAsync(InvocationContext context)
Configuration.Generation.ApiManifestPath = NormalizeSlashesInPath(GetAbsolutePath(Configuration.Generation.ApiManifestPath));
Configuration.Generation.CleanOutput = cleanOutput;
Configuration.Generation.ClearCache = clearCache;
Configuration.Generation.DisableSSLValidation = disableSSLValidation;

var (loggerFactory, logger) = GetLoggerAndFactory<KiotaBuilder>(context, Configuration.Generation.OutputPath);
using (loggerFactory)
Expand Down Expand Up @@ -173,4 +175,8 @@ public required Option<bool> ExcludeBackwardCompatibleOption
get;
set;
}
public required Option<bool> DisableSSLValidationOption
{
get; init;
}
}
6 changes: 6 additions & 0 deletions src/kiota/Handlers/KiotaShowCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public required Option<string> ManifestOption
{
get; init;
}
public required Option<bool> DisableSSLValidationOption
{
get; init;
}

public override async Task<int> InvokeAsync(InvocationContext context)
{
Expand All @@ -52,11 +56,13 @@ public override async Task<int> InvokeAsync(InvocationContext context)
List<string> includePatterns = context.ParseResult.GetValueForOption(IncludePatternsOption) ?? new List<string>();
List<string> excludePatterns = context.ParseResult.GetValueForOption(ExcludePatternsOption) ?? new List<string>();
bool clearCache = context.ParseResult.GetValueForOption(ClearCacheOption);
bool disableSSLValidation = context.ParseResult.GetValueForOption(DisableSSLValidationOption);
CancellationToken cancellationToken = context.BindingContext.GetService(typeof(CancellationToken)) is CancellationToken token ? token : CancellationToken.None;

var (loggerFactory, logger) = GetLoggerAndFactory<KiotaBuilder>(context);

Configuration.Search.ClearCache = clearCache;
Configuration.Generation.DisableSSLValidation = disableSSLValidation;
using (loggerFactory)
{
await CheckForNewVersionAsync(logger, cancellationToken).ConfigureAwait(false);
Expand Down
Loading

0 comments on commit 17b08be

Please sign in to comment.