Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9aa74d4
Examine ResourceType to decide how to handle image resource identifier
Porges Sep 9, 2022
f11bd5e
Make it a 'proper' discriminated union that can be used everywhere
Porges Sep 9, 2022
6cf5544
Format
Porges Sep 9, 2022
dd40d4a
Multiple options for generator
Porges Sep 9, 2022
b9f51d8
Renaming, add in shared gallery images
Porges Sep 9, 2022
5bb43bc
Fixup after rebase
Porges Sep 11, 2022
d060da8
Update documentation
Porges Sep 12, 2022
a3d1ecd
Fixup after rebase
Porges Sep 15, 2022
cd4ef0e
Merge remote-tracking branch 'origin/main' into examine-resource-id
Porges Sep 26, 2022
98f9659
Merge branch 'main' into examine-resource-id
Porges Sep 28, 2022
900a95b
Merge remote-tracking branch 'origin/main' into examine-resource-id
Porges Sep 29, 2022
7c4feff
Merge remote-tracking branch 'origin/main' into examine-resource-id
Porges Oct 4, 2022
34d0c2a
Merge branch 'main' into examine-resource-id
Porges Oct 5, 2022
414b1da
Merge branch 'main' into examine-resource-id
Porges Oct 5, 2022
0168209
Merge branch 'main' into examine-resource-id
Porges Nov 3, 2022
0bc560e
Merge branch 'main' into examine-resource-id
Porges Dec 5, 2022
21e44ef
Merge remote-tracking branch 'origin/main' into examine-resource-id
Porges Dec 15, 2022
d2efc3c
Update version
Porges Dec 15, 2022
2267904
Merge branch 'main' into examine-resource-id
Porges Dec 19, 2022
3d0c30a
Fix build
Porges Dec 19, 2022
17464d1
Merge branch 'main' into examine-resource-id
Porges Feb 16, 2023
db26d21
Fix format/code
Porges Feb 16, 2023
592ba11
Fixup
Porges Feb 16, 2023
236d59e
Merge branch 'main' into examine-resource-id
Porges Feb 16, 2023
f481880
Merge branch 'main' into examine-resource-id
Porges Feb 16, 2023
e3c7ff1
Merge branch 'main' into examine-resource-id
Porges Mar 21, 2023
f6c44a4
Fix build
Porges Mar 21, 2023
f006f79
Fix Focal image name
Porges Mar 22, 2023
c899cc3
Merge branch 'main' into examine-resource-id
Porges Mar 22, 2023
04ca913
Restore caching on GetOs
Porges Mar 22, 2023
ef8c33a
Seal CacheKey
Porges Mar 22, 2023
03f04ae
Fix test build
Porges Mar 22, 2023
17c6d75
Merge branch 'main' into examine-resource-id
Porges Mar 26, 2023
d195d5a
Merge branch 'main' into examine-resource-id
Porges Mar 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions docs/custom-images.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
# Fuzzing using Custom OS Images

In order to use custom OS images in OneFzuz, the image _must_ run the
[Azure VM Agent](https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/overview).
In order to use custom OS images in OneFuzz, the image _must_ run the [Azure VM
Agent](https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/overview).

Building custom images can be automated using the
[Linux](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/image-builder)
or
[Windows](https://docs.microsoft.com/en-us/azure/virtual-machines/windows/image-builder)
image builders for Azure.

If you have a custom Windows VHD, you should follow the
[Guide to prepare a VHD for Azure](https://docs.microsoft.com/en-us/azure/virtual-machines/windows/prepare-for-upload-vhd-image).
If you have a custom Windows VHD, you should follow the [Guide to prepare a VHD
for
Azure](https://docs.microsoft.com/en-us/azure/virtual-machines/windows/prepare-for-upload-vhd-image).

From there, rather than using Image SKUs such as
`Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest`, use the full resource ID to the
shared image, such as
`/subscriptions/MYSUBSCRIPTION/resourceGroups/MYGROUP/providers/Microsoft.Compute/galleries/MYGALLERY/images/MYDEFINITION/versions/MYVERSION`
`Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest`, use the full resource ID for the
shared image. Supported ID formats are:

The images must be hosted in a
[Shared Image Gallery](https://docs.microsoft.com/en-us/azure/virtual-machines/windows/shared-image-galleries).
The Service Principal for the OneFuzz instance must have RBAC to the shared
image gallery sufficient to deploy the images.
- VM image:<br/>
`/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{image}`
- gallery image (latest):<br/>
`/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{gallery}/images/{image}`
- gallery image (specific version):<br/>
`/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{gallery}/images/{image}/versions/{version}`
- shared gallery image (latest):<br/>
`/subscriptions/{subscription}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{gallery}/images/{image}`,
- shared gallery image (specific version):<br/>
`/subscriptions/{subscription}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{gallery}/images/{image}/versions/{version}`

The Service Principal for the OneFuzz instance must have RBAC to the image
sufficient to read and deploy the images, and the image must be replicated into
the region of the scaleset.
6 changes: 3 additions & 3 deletions src/ApiService/ApiService/Functions/Scaleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ private async Task<HttpResponseData> Post(HttpRequestData req) {
context: "ScalesetCreate");
}

string image;
ImageReference image;
if (create.Image is null) {
var config = await _context.ConfigOperations.Fetch();
if (pool.Os == Os.Windows) {
image = config.DefaultWindowsVmImage;
image = config.DefaultWindowsVmImage ?? DefaultImages.Windows;
} else {
image = config.DefaultLinuxVmImage;
image = config.DefaultLinuxVmImage ?? DefaultImages.Linux;
}
} else {
image = create.Image;
Expand Down
33 changes: 14 additions & 19 deletions src/ApiService/ApiService/OneFuzzTypes/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public record TaskDetails(
public record TaskVm(
Region Region,
string Sku,
string Image,
ImageReference Image,
bool? RebootAfterSetup,
long Count = 1,
bool SpotInstance = false
Expand Down Expand Up @@ -345,28 +345,23 @@ public record InstanceConfig
string[] AllowedAadTenants,
[DefaultValue(InitMethod.DefaultConstructor)] NetworkConfig NetworkConfig,
[DefaultValue(InitMethod.DefaultConstructor)] NetworkSecurityGroupConfig ProxyNsgConfig,
AzureVmExtensionConfig? Extensions,
string DefaultWindowsVmImage = "MicrosoftWindowsDesktop:Windows-10:win10-21h2-pro:latest",
string DefaultLinuxVmImage = "Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest",
AzureVmExtensionConfig? Extensions = null,
ImageReference? DefaultWindowsVmImage = null,
ImageReference? DefaultLinuxVmImage = null,
string ProxyVmSku = "Standard_B2s",
bool RequireAdminPrivileges = false,
IDictionary<Endpoint, ApiAccessRule>? ApiAccessRules = null,
IDictionary<PrincipalId, GroupId[]>? GroupMembership = null,
IDictionary<string, string>? VmTags = null,
IDictionary<string, string>? VmssTags = null
) : EntityBase() {

public InstanceConfig(string instanceName) : this(
instanceName,
null,
Array.Empty<string>(),
new NetworkConfig(),
new NetworkSecurityGroupConfig(),
null,
"MicrosoftWindowsDesktop:Windows-10:win10-21h2-pro:latest",
"Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest",
"Standard_B2s",
false
) { }
InstanceName: instanceName,
Admins: null,
AllowedAadTenants: Array.Empty<string>(),
NetworkConfig: new NetworkConfig(),
ProxyNsgConfig: new NetworkSecurityGroupConfig()) { }

public static List<Guid>? CheckAdmins(List<Guid>? value) {
if (value is not null && value.Count == 0) {
Expand All @@ -378,8 +373,8 @@ public InstanceConfig(string instanceName) : this(

public InstanceConfig() : this(String.Empty) { }

//# At the moment, this only checks allowed_aad_tenants, however adding
//# support for 3rd party JWT validation is anticipated in a future release.
// At the moment, this only checks allowed_aad_tenants, however adding
// support for 3rd party JWT validation is anticipated in a future release.
public ResultVoid<List<string>> CheckInstanceConfig() {
List<string> errors = new();
if (AllowedAadTenants.Length == 0) {
Expand Down Expand Up @@ -415,7 +410,7 @@ public record Scaleset(
[RowKey] Guid ScalesetId,
ScalesetState State,
string VmSku,
string Image,
ImageReference Image,
Region Region,
long Size,
bool? SpotInstances,
Expand Down Expand Up @@ -757,7 +752,7 @@ public record Vm(
string Name,
Region Region,
string Sku,
string Image,
ImageReference Image,
Authentication Auth,
Nsg? Nsg,
IDictionary<string, string>? Tags
Expand Down
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/OneFuzzTypes/Requests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public record ProxyReset(
public record ScalesetCreate(
[property: Required] PoolName PoolName,
[property: Required] string VmSku,
string? Image,
ImageReference? Image,
Region? Region,
[property: Range(1, long.MaxValue), Required] long Size,
[property: Required] bool SpotInstances,
Expand Down
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/OneFuzzTypes/Responses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public record ScalesetResponse(
ScalesetState State,
Authentication? Auth,
string VmSku,
string Image,
ImageReference Image,
Region Region,
long Size,
bool? SpotInstances,
Expand Down
1 change: 0 additions & 1 deletion src/ApiService/ApiService/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public static async Async.Task Main() {
.AddScoped<INodeTasksOperations, NodeTasksOperations>()
.AddScoped<INodeMessageOperations, NodeMessageOperations>()
.AddScoped<IRequestHandling, RequestHandling>()
.AddScoped<IImageOperations, ImageOperations>()
.AddScoped<ITeams, Teams>()
.AddScoped<IGithubIssues, GithubIssues>()
.AddScoped<IAdo, Ado>()
Expand Down
141 changes: 0 additions & 141 deletions src/ApiService/ApiService/onefuzzlib/ImageOperations.cs

This file was deleted.

Loading