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

Commit

Permalink
Add an event for Repro VM creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Porges authored May 9, 2023
1 parent 69171af commit 392e4cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/ApiService/ApiService/Functions/ReproVmss.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Net;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;

Expand Down Expand Up @@ -81,6 +84,14 @@ private async Async.Task<HttpResponseData> Post(HttpRequestData req) {
"repro_vm create");
}

// we’d like to track the usage of this feature;
// anonymize the user ID so we can distinguish multiple requests
{
var data = userInfo.OkV.UserInfo.ToString(); // rely on record ToString
var hash = Convert.ToBase64String(SHA256.HashData(Encoding.UTF8.GetBytes(data)));
_log.Event($"created repro VM, user distinguisher: {hash:Tag:UserHash}");
}

var response = req.CreateResponse(HttpStatusCode.OK);
await response.WriteAsJsonAsync(vm.OkV);
return response;
Expand Down
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.OneFuzz.Service;
[InterpolatedStringHandler]
public struct LogStringHandler {

private StringBuilder _builder;
private readonly StringBuilder _builder;
private Dictionary<string, string>? _tags;

public LogStringHandler(int literalLength, int formattedCount) {
Expand Down

0 comments on commit 392e4cb

Please sign in to comment.