是否可以将 yaml 模板嵌套在另一个 yaml 模板中?
我在不同的 Git 存储库中有多个 NuGet 项目,我正在尝试模板化在 nuget.org 上发布 NuGet 的过程。
所以我创建了一个名为“devops-templates”的 git 仓库,做了第一个 yaml 模板,确保它可以工作,然后将它分成 4 个 yaml 模板(构建解决方案,生成包,运行单元测试,发布),并将它们引用到全局 yaml 模板。
问题是当我尝试在我的管道中使用这个全局模板时,我得到了错误
/Net/Utilities/BuildSolution.yml@templates (Line: 33, Col: 18): A template expression is not allowed in this context,/Net/Utilities/BuildSolution.yml@templates (Line: 36, Col: 21): A template expression is not allowed in this context,/Net/Utilities/BuildSolution.yml@templates (Line: 48, Col: 24): A template expression is not allowed in this context,/Net/Utilities/BuildSolution.yml@templates (Line: 53, Col: 28): A template expression is not allowed in this context,/Net/Utilities/BuildSolution.yml@templates (Line: …
我正在开发 .NET 6 API,并尝试使用 Serilog 记录所有用户操作。
我想做到这一点,而不必添加_logger.Info(...);
用户请求和响应的每个端点。
在互联网上查看后,我发现可以使用UseSerilogRequestLogging()
. 它工作得很好,但问题在于敏感数据。出于安全原因,某些数据(例如电子邮件、密码等)不应位于日志中。
所以问题是:如何记录所有用户请求和响应,同时出于安全原因隐藏敏感数据?
此 API 的一些代码:
获取日志中的数据:
app.UseHttpLogging()
.UseSerilogRequestLogging();
Run Code Online (Sandbox Code Playgroud)
builder.Services.AddHttpLogging(logging =>
{
logging.LoggingFields = HttpLoggingFields.All;
logging.RequestHeaders.Add(HeaderNames.Accept);
logging.RequestHeaders.Add(HeaderNames.ContentType);
logging.RequestHeaders.Add(HeaderNames.ContentDisposition);
logging.RequestHeaders.Add(HeaderNames.ContentEncoding);
logging.RequestHeaders.Add(HeaderNames.ContentLength);
logging.MediaTypeOptions.AddText("application/json");
logging.MediaTypeOptions.AddText("multipart/form-data");
logging.RequestBodyLogLimit = 4096;
logging.ResponseBodyLogLimit = 4096;
});
Run Code Online (Sandbox Code Playgroud)
记录配置并尝试隐藏敏感数据:
builder.Host.UseSerilog((context, services, configuration) => configuration
.ReadFrom.Configuration(context.Configuration)
.ReadFrom.Services(services)
.Enrich.FromLogContext()
.Enrich.With<UserEnricher>()
.Destructure.ByTransforming<AddUserDto>(_ => new AddUserDto()
{
UserName = _.UserName, UserDescription = _.UserDescription, Password = "****", Email = "****"
})
.Destructure.ByTransforming<UserLoginDto>(_ => new UserLoginDto()
{
UserName = _.UserName,
Password = "****"
}) …
Run Code Online (Sandbox Code Playgroud)