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

Commit

Permalink
Merge branch 'main' into 8.6.3-Hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamL-Microsoft authored Aug 3, 2023
2 parents 19841b4 + ab189b1 commit cd782bb
Show file tree
Hide file tree
Showing 32 changed files with 190 additions and 2,045 deletions.
196 changes: 98 additions & 98 deletions contrib/deploy-onefuzz-via-azure-devops/Pipfile.lock

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions src/ApiService/ApiService/Functions/Jobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,14 @@ private async Task<HttpResponseData> Get(HttpRequestData req) {

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

// TODO: search.WithTasks is not checked in Python code?

var taskInfo = await _context.TaskOperations.SearchStates(jobId).Select(TaskToJobTaskInfo).ToListAsync();
return await RequestHandling.Ok(req, JobResponse.ForJob(job, taskInfo));
var tasks = _context.TaskOperations.SearchStates(jobId);
if (search.WithTasks ?? false) {
var ts = await tasks.ToListAsync();
return await RequestHandling.Ok(req, JobResponse.ForJob(job, ts));
} else {
var taskInfo = await tasks.Select(TaskToJobTaskInfo).ToListAsync();
return await RequestHandling.Ok(req, JobResponse.ForJob(job, taskInfo));
}
}

var jobs = await _context.JobOperations.SearchState(states: search.State ?? Enumerable.Empty<JobState>()).ToListAsync();
Expand Down
13 changes: 11 additions & 2 deletions src/ApiService/ApiService/OneFuzzTypes/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ public record Task(
ISecret<Authentication>? Auth = null,
DateTimeOffset? Heartbeat = null,
DateTimeOffset? EndTime = null,
StoredUserInfo? UserInfo = null) : StatefulEntityBase<TaskState>(State) {
StoredUserInfo? UserInfo = null) : StatefulEntityBase<TaskState>(State), IJobTaskInfo {
public TaskType Type => Config.Task.Type;
}

public record TaskEvent(
Expand Down Expand Up @@ -909,11 +910,19 @@ public JobConfig Truncate(int maxLength) {
}
}

[JsonDerivedType(typeof(Task), typeDiscriminator: "Task")]
[JsonDerivedType(typeof(JobTaskInfo), typeDiscriminator: "JobTaskInfo")]
public interface IJobTaskInfo {
Guid TaskId { get; }
TaskType Type { get; }
TaskState State { get; }
}

public record JobTaskInfo(
Guid TaskId,
TaskType Type,
TaskState State
);
) : IJobTaskInfo;

public record Job(
[PartitionKey][RowKey] Guid JobId,
Expand Down
4 changes: 2 additions & 2 deletions src/ApiService/ApiService/OneFuzzTypes/Responses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ public record JobResponse(
JobConfig Config,
string? Error,
DateTimeOffset? EndTime,
List<JobTaskInfo>? TaskInfo,
IEnumerable<IJobTaskInfo>? TaskInfo,
StoredUserInfo? UserInfo,
[property: JsonPropertyName("Timestamp")] // must retain capital T for backcompat
DateTimeOffset? Timestamp
// not including UserInfo from Job model
) : BaseResponse() {
public static JobResponse ForJob(Job j, List<JobTaskInfo>? taskInfo)
public static JobResponse ForJob(Job j, IEnumerable<IJobTaskInfo>? taskInfo)
=> new(
JobId: j.JobId,
State: j.State,
Expand Down
51 changes: 51 additions & 0 deletions src/ApiService/IntegrationTests/JobsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,55 @@ public async Async.Task Post_CreatesJob_AndContainer() {
var metadata = Assert.Single(container.Value);
Assert.Equal(new KeyValuePair<string, string>("container_type", "logs"), metadata);
}


[Fact]
public async Async.Task Get_CanFindSpecificJobWithTaskInfo() {

var taskConfig = new TaskConfig(_jobId, new List<Guid>(), new TaskDetails(TaskType.Coverage, 60));
var task = new Task(_jobId, Guid.NewGuid(), TaskState.Running, Os.Windows, taskConfig);

await Context.InsertAll(
new Job(_jobId, JobState.Stopped, _config, null), task);

var func = new Jobs(Context, LoggerProvider.CreateLogger<Jobs>());

var ctx = new TestFunctionContext();
var result = await func.Run(TestHttpRequestData.FromJson("GET", new JobSearch(JobId: _jobId, WithTasks: false)), ctx);
Assert.Equal(HttpStatusCode.OK, result.StatusCode);

var response = BodyAs<JobResponse>(result);
Assert.Equal(_jobId, response.JobId);
Assert.NotNull(response.TaskInfo);
var returnedTasks = response.TaskInfo.OfType<JobTaskInfo>().ToList();
Assert.NotEmpty(returnedTasks);
Assert.Equal(task.TaskId, returnedTasks[0].TaskId);
Assert.Equal(task.State, returnedTasks[0].State);
Assert.Equal(task.Config.Task.Type, returnedTasks[0].Type);
}

[Fact]
public async Async.Task Get_CanFindSpecificJobWithFullTask() {
var taskConfig = new TaskConfig(_jobId, new List<Guid>(), new TaskDetails(TaskType.Coverage, 60));
var task = new Task(_jobId, Guid.NewGuid(), TaskState.Running, Os.Windows, taskConfig);

await Context.InsertAll(
new Job(_jobId, JobState.Stopped, _config, null), task);

var func = new Jobs(Context, LoggerProvider.CreateLogger<Jobs>());

var ctx = new TestFunctionContext();
var result = await func.Run(TestHttpRequestData.FromJson("GET", new JobSearch(JobId: _jobId, WithTasks: true)), ctx);
Assert.Equal(HttpStatusCode.OK, result.StatusCode);

var response = BodyAs<JobResponse>(result);
Assert.Equal(_jobId, response.JobId);
Assert.NotNull(response.TaskInfo);
var returnedTasks = response.TaskInfo.OfType<Task>().ToList();
Assert.NotEmpty(returnedTasks);
Assert.Equal(task.TaskId, returnedTasks[0].TaskId);
Assert.Equal(task.State, returnedTasks[0].State);
Assert.Equal(task.Config.Task.Type, returnedTasks[0].Type);

}
}
15 changes: 0 additions & 15 deletions src/agent/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ members = [
"onefuzz-file-format",
"onefuzz-telemetry",
"reqwest-retry",
"srcview",
"storage-queue",
"win-util",
"libclusterfuzz",
Expand Down
1 change: 1 addition & 0 deletions src/agent/debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ features = [
"dbghelp",
"debugapi",
"handleapi",
"impl-default",
"memoryapi",
"namedpipeapi",
"processthreadsapi",
Expand Down
4 changes: 3 additions & 1 deletion src/agent/onefuzz/src/libfuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,10 @@ impl LibFuzzer {

if !result.status.success() {
bail!(
"libFuzzer failed when parsing an initial seed {:?}: stdout:{:?} stderr:{:?}",
"libFuzzer failed when parsing an initial seed {:?}: cmd:{:?} exit_code: {:?} stdout:{:?} stderr:{:?}",
input.file_name().unwrap_or_else(|| input.as_ref()),
cmd,
result.status,
String::from_utf8_lossy(&result.stdout),
String::from_utf8_lossy(&result.stderr),
);
Expand Down
1 change: 0 additions & 1 deletion src/agent/srcview/.gitignore

This file was deleted.

21 changes: 0 additions & 21 deletions src/agent/srcview/Cargo.toml

This file was deleted.

34 changes: 0 additions & 34 deletions src/agent/srcview/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions src/agent/srcview/TODO.md

This file was deleted.

59 changes: 0 additions & 59 deletions src/agent/srcview/examples/dump_cobertura.rs

This file was deleted.

19 changes: 0 additions & 19 deletions src/agent/srcview/examples/dump_modoff.rs

This file was deleted.

27 changes: 0 additions & 27 deletions src/agent/srcview/examples/dump_paths.rs

This file was deleted.

31 changes: 0 additions & 31 deletions src/agent/srcview/examples/dump_srcloc.rs

This file was deleted.

15 changes: 0 additions & 15 deletions src/agent/srcview/res/example.txt

This file was deleted.

Loading

0 comments on commit cd782bb

Please sign in to comment.