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

Commit cd782bb

Browse files
Merge branch 'main' into 8.6.3-Hotfix
2 parents 19841b4 + ab189b1 commit cd782bb

File tree

32 files changed

+190
-2045
lines changed

32 files changed

+190
-2045
lines changed

contrib/deploy-onefuzz-via-azure-devops/Pipfile.lock

Lines changed: 98 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ApiService/ApiService/Functions/Jobs.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,14 @@ private async Task<HttpResponseData> Get(HttpRequestData req) {
135135

136136
static JobTaskInfo TaskToJobTaskInfo(Task t) => new(t.TaskId, t.Config.Task.Type, t.State);
137137

138-
// TODO: search.WithTasks is not checked in Python code?
139-
140-
var taskInfo = await _context.TaskOperations.SearchStates(jobId).Select(TaskToJobTaskInfo).ToListAsync();
141-
return await RequestHandling.Ok(req, JobResponse.ForJob(job, taskInfo));
138+
var tasks = _context.TaskOperations.SearchStates(jobId);
139+
if (search.WithTasks ?? false) {
140+
var ts = await tasks.ToListAsync();
141+
return await RequestHandling.Ok(req, JobResponse.ForJob(job, ts));
142+
} else {
143+
var taskInfo = await tasks.Select(TaskToJobTaskInfo).ToListAsync();
144+
return await RequestHandling.Ok(req, JobResponse.ForJob(job, taskInfo));
145+
}
142146
}
143147

144148
var jobs = await _context.JobOperations.SearchState(states: search.State ?? Enumerable.Empty<JobState>()).ToListAsync();

src/ApiService/ApiService/OneFuzzTypes/Model.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ public record Task(
282282
ISecret<Authentication>? Auth = null,
283283
DateTimeOffset? Heartbeat = null,
284284
DateTimeOffset? EndTime = null,
285-
StoredUserInfo? UserInfo = null) : StatefulEntityBase<TaskState>(State) {
285+
StoredUserInfo? UserInfo = null) : StatefulEntityBase<TaskState>(State), IJobTaskInfo {
286+
public TaskType Type => Config.Task.Type;
286287
}
287288

288289
public record TaskEvent(
@@ -909,11 +910,19 @@ public JobConfig Truncate(int maxLength) {
909910
}
910911
}
911912

913+
[JsonDerivedType(typeof(Task), typeDiscriminator: "Task")]
914+
[JsonDerivedType(typeof(JobTaskInfo), typeDiscriminator: "JobTaskInfo")]
915+
public interface IJobTaskInfo {
916+
Guid TaskId { get; }
917+
TaskType Type { get; }
918+
TaskState State { get; }
919+
}
920+
912921
public record JobTaskInfo(
913922
Guid TaskId,
914923
TaskType Type,
915924
TaskState State
916-
);
925+
) : IJobTaskInfo;
917926

918927
public record Job(
919928
[PartitionKey][RowKey] Guid JobId,

src/ApiService/ApiService/OneFuzzTypes/Responses.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ public record JobResponse(
9696
JobConfig Config,
9797
string? Error,
9898
DateTimeOffset? EndTime,
99-
List<JobTaskInfo>? TaskInfo,
99+
IEnumerable<IJobTaskInfo>? TaskInfo,
100100
StoredUserInfo? UserInfo,
101101
[property: JsonPropertyName("Timestamp")] // must retain capital T for backcompat
102102
DateTimeOffset? Timestamp
103103
// not including UserInfo from Job model
104104
) : BaseResponse() {
105-
public static JobResponse ForJob(Job j, List<JobTaskInfo>? taskInfo)
105+
public static JobResponse ForJob(Job j, IEnumerable<IJobTaskInfo>? taskInfo)
106106
=> new(
107107
JobId: j.JobId,
108108
State: j.State,

src/ApiService/IntegrationTests/JobsTests.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,55 @@ public async Async.Task Post_CreatesJob_AndContainer() {
175175
var metadata = Assert.Single(container.Value);
176176
Assert.Equal(new KeyValuePair<string, string>("container_type", "logs"), metadata);
177177
}
178+
179+
180+
[Fact]
181+
public async Async.Task Get_CanFindSpecificJobWithTaskInfo() {
182+
183+
var taskConfig = new TaskConfig(_jobId, new List<Guid>(), new TaskDetails(TaskType.Coverage, 60));
184+
var task = new Task(_jobId, Guid.NewGuid(), TaskState.Running, Os.Windows, taskConfig);
185+
186+
await Context.InsertAll(
187+
new Job(_jobId, JobState.Stopped, _config, null), task);
188+
189+
var func = new Jobs(Context, LoggerProvider.CreateLogger<Jobs>());
190+
191+
var ctx = new TestFunctionContext();
192+
var result = await func.Run(TestHttpRequestData.FromJson("GET", new JobSearch(JobId: _jobId, WithTasks: false)), ctx);
193+
Assert.Equal(HttpStatusCode.OK, result.StatusCode);
194+
195+
var response = BodyAs<JobResponse>(result);
196+
Assert.Equal(_jobId, response.JobId);
197+
Assert.NotNull(response.TaskInfo);
198+
var returnedTasks = response.TaskInfo.OfType<JobTaskInfo>().ToList();
199+
Assert.NotEmpty(returnedTasks);
200+
Assert.Equal(task.TaskId, returnedTasks[0].TaskId);
201+
Assert.Equal(task.State, returnedTasks[0].State);
202+
Assert.Equal(task.Config.Task.Type, returnedTasks[0].Type);
203+
}
204+
205+
[Fact]
206+
public async Async.Task Get_CanFindSpecificJobWithFullTask() {
207+
var taskConfig = new TaskConfig(_jobId, new List<Guid>(), new TaskDetails(TaskType.Coverage, 60));
208+
var task = new Task(_jobId, Guid.NewGuid(), TaskState.Running, Os.Windows, taskConfig);
209+
210+
await Context.InsertAll(
211+
new Job(_jobId, JobState.Stopped, _config, null), task);
212+
213+
var func = new Jobs(Context, LoggerProvider.CreateLogger<Jobs>());
214+
215+
var ctx = new TestFunctionContext();
216+
var result = await func.Run(TestHttpRequestData.FromJson("GET", new JobSearch(JobId: _jobId, WithTasks: true)), ctx);
217+
Assert.Equal(HttpStatusCode.OK, result.StatusCode);
218+
219+
var response = BodyAs<JobResponse>(result);
220+
Assert.Equal(_jobId, response.JobId);
221+
Assert.NotNull(response.TaskInfo);
222+
var returnedTasks = response.TaskInfo.OfType<Task>().ToList();
223+
Assert.NotEmpty(returnedTasks);
224+
Assert.Equal(task.TaskId, returnedTasks[0].TaskId);
225+
Assert.Equal(task.State, returnedTasks[0].State);
226+
Assert.Equal(task.Config.Task.Type, returnedTasks[0].Type);
227+
228+
}
178229
}

src/agent/Cargo.lock

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/agent/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ members = [
1313
"onefuzz-file-format",
1414
"onefuzz-telemetry",
1515
"reqwest-retry",
16-
"srcview",
1716
"storage-queue",
1817
"win-util",
1918
"libclusterfuzz",

src/agent/debugger/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ features = [
2222
"dbghelp",
2323
"debugapi",
2424
"handleapi",
25+
"impl-default",
2526
"memoryapi",
2627
"namedpipeapi",
2728
"processthreadsapi",

src/agent/onefuzz/src/libfuzzer.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,10 @@ impl LibFuzzer {
278278

279279
if !result.status.success() {
280280
bail!(
281-
"libFuzzer failed when parsing an initial seed {:?}: stdout:{:?} stderr:{:?}",
281+
"libFuzzer failed when parsing an initial seed {:?}: cmd:{:?} exit_code: {:?} stdout:{:?} stderr:{:?}",
282282
input.file_name().unwrap_or_else(|| input.as_ref()),
283+
cmd,
284+
result.status,
283285
String::from_utf8_lossy(&result.stdout),
284286
String::from_utf8_lossy(&result.stderr),
285287
);

src/agent/srcview/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)