Skip to content

Commit 1abbff9

Browse files
Merge pull request #147 from microsoft/main
Fork Sync: Update from parent repository
2 parents 0f1a6c9 + 349604f commit 1abbff9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3557
-531
lines changed

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

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

docs/unmnaged-nodes.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Unmanaged Nodes
2+
The default mode of OneFuzz is to run the agents inside scalesets managed by the the Onefuzz instance. But it is possible to run outside of the Instance infrastructure.
3+
This is the unmanaged scenario. In this mode, the user can use their own resource to participate in the fuzzing.
4+
5+
## Set-up
6+
These are the steps to run an unmanaged node
7+
8+
9+
### Create an Application Registration in Azure Active Directory
10+
We will create the authentication method for the unmanaged node.
11+
From the [azure cli](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) create a new **application registration**:
12+
```cmd
13+
az ad app create --display-name <registration_name>
14+
```
15+
Then use the application `app_id` in the result to create the associated **service principal**:
16+
17+
```cmd
18+
az ad sp create --id <app_id>
19+
```
20+
Take note of the `id` returned by this request. We will call it the `principal_id`.
21+
22+
Next, create a `client_secret`:
23+
24+
```
25+
az ad app credential reset --id <pp_id> --append
26+
```
27+
Take note of the `password` returned.
28+
29+
### Authorize the application in OneFuzz
30+
From the OneFuzz `deployment` folder run the following script using the `app_id` from above:
31+
``` cmd
32+
python .\deploylib\registration.py register_app <onefuzz_instance_id> <subscription_id> --app_id <app_id> --role UnmanagedNode
33+
```
34+
35+
### Create an unmanaged pool
36+
Using the OneFuzz CLI:
37+
``` cmd
38+
onefuzz pools create <pool_name> <os> --unmanaged --object_id <principal_id>
39+
```
40+
41+
### Download the agent binaries and the agent configuration
42+
Download a zip file containing the agent binaries:
43+
```
44+
onefuzz tools get <destination_folder>
45+
```
46+
Extract the zip file in a folder of your choice.
47+
48+
Download the configuration file for the agent:
49+
50+
```
51+
onefuzz pools get_config <pool_name>
52+
```
53+
54+
Under the `client_credential` section of the agent config file, update `client_id` and `client_secret`:
55+
```json
56+
{
57+
"client_id": "<app_id>",
58+
"client_secret": "<password>",
59+
}
60+
```
61+
Save the config to the file.
62+
63+
### Start the agent.
64+
Navigate to the folder corresponding to your OS.
65+
Set the necessary environment variable by running the script `set-env.ps1` (for Windows) or `set-env.sh` (for Linux).
66+
Run the agent with the following command. If you need more nodes use a different `machine_guid` for each one:
67+
```cmd
68+
onefuzz-agent run --machine_id <machine_guid> -c <path_to_config_file> --reset_lock
69+
```
70+
71+
### Verify that the agent is registered to OneFuzz
72+
73+
Using the OneFuzz CLI run the following command:
74+
75+
```
76+
onefuzz nodes get <machine_guid>
77+
```
78+
79+
This should return one entry. Verify that the `pool_name` matched the pool name created earlier.
80+
From here you will be able to schedule jobs on that pool and they will be running.

src/ApiService/ApiService/Functions/AgentRegistration.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ private async Async.Task<HttpResponseData> Post(HttpRequestData req) {
152152
MachineId: machineId,
153153
ScalesetId: scalesetId,
154154
InstanceId: instanceId,
155-
Version: version
155+
Version: version,
156+
Os: os ?? pool.Os,
157+
Managed: pool.Managed
156158
);
157159

158160
var r = await _context.NodeOperations.Replace(node);

src/ApiService/ApiService/GroupMembershipChecker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public async ValueTask<bool> IsMember(IEnumerable<Guid> groupIds, Guid memberId)
1515
}
1616
}
1717

18-
class AzureADGroupMembership : GroupMembershipChecker {
18+
sealed class AzureADGroupMembership : GroupMembershipChecker {
1919
private readonly GraphServiceClient _graphClient;
2020
public AzureADGroupMembership(GraphServiceClient graphClient) => _graphClient = graphClient;
2121
protected override async IAsyncEnumerable<Guid> GetGroups(Guid memberId) {
@@ -30,7 +30,7 @@ protected override async IAsyncEnumerable<Guid> GetGroups(Guid memberId) {
3030
}
3131
}
3232

33-
class StaticGroupMembership : GroupMembershipChecker {
33+
sealed class StaticGroupMembership : GroupMembershipChecker {
3434
private readonly IReadOnlyDictionary<Guid, IReadOnlyList<Guid>> _memberships;
3535
public StaticGroupMembership(IDictionary<Guid, Guid[]> memberships) {
3636
_memberships = memberships.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList<Guid>)kvp.Value.ToList());

src/ApiService/ApiService/Log.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public interface ILog {
6161
void Flush();
6262
}
6363

64-
class AppInsights : ILog {
64+
sealed class AppInsights : ILog {
6565
private readonly TelemetryClient _telemetryClient;
6666

6767
public AppInsights(TelemetryClient client) {
@@ -128,7 +128,7 @@ public void Flush() {
128128
}
129129

130130
//TODO: Should we write errors and Exception to std err ?
131-
class Console : ILog {
131+
sealed class Console : ILog {
132132

133133
private static string DictToString<T>(IReadOnlyDictionary<string, T>? d) {
134134
if (d is null) {

0 commit comments

Comments
 (0)