Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit c718a4e

Browse files
committed
Do not enforce that key exists in dictionary when doing strict validation
1 parent 3f9bc97 commit c718a4e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/ApiService/ApiService/onefuzzlib/notifications/NotificationsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public async Async.Task<string> Render(string templateString, Uri instanceUrl, b
138138
true => new TemplateContext {
139139
EnableRelaxedFunctionAccess = false,
140140
EnableRelaxedIndexerAccess = false,
141-
EnableRelaxedMemberAccess = false,
141+
EnableRelaxedMemberAccess = true,
142142
EnableRelaxedTargetAccess = false
143143
},
144144
_ => new TemplateContext()

src/ApiService/IntegrationTests/JinjaToScribanMigrationTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,12 @@ public async Async.Task Access_WithoutAuthorization_IsRejected() {
362362
result.StatusCode.Should().Be(System.Net.HttpStatusCode.BadRequest);
363363
}
364364

365+
[Fact]
366+
public async Async.Task Do_Not_Enforce_Key_Exists_In_Strict_Validation() {
367+
(await JinjaTemplateAdapter.IsValidScribanNotificationTemplate(Context, Logger, ValidScribanAdoTemplate()))
368+
.Should().BeTrue();
369+
}
370+
365371
private async Async.Task ConfigureAuth() {
366372
await Context.InsertAll(
367373
new InstanceConfig(Context.ServiceConfiguration.OneFuzzInstanceName!) { Admins = new[] { _userObjectId } } // needed for admin check
@@ -412,4 +418,19 @@ private static GithubIssuesTemplate MigratableGithubTemplate() {
412418
private static TeamsTemplate GetTeamsTemplate() {
413419
return new TeamsTemplate(new SecretData<string>(new SecretValue<string>("https://example.com")));
414420
}
421+
422+
private static AdoTemplate ValidScribanAdoTemplate() {
423+
return new AdoTemplate(
424+
new Uri("http://example.com"),
425+
new SecretData<string>(new SecretValue<string>("some secret")),
426+
"{{ if task.tags.project }} blah {{ end }}",
427+
string.Empty,
428+
Array.Empty<string>().ToList(),
429+
new Dictionary<string, string>(),
430+
new ADODuplicateTemplate(
431+
Array.Empty<string>().ToList(),
432+
new Dictionary<string, string>(),
433+
new Dictionary<string, string>()
434+
));
435+
}
415436
}

0 commit comments

Comments
 (0)