Skip to content

Commit

Permalink
upgrade to .net 6.0 LTS
Browse files Browse the repository at this point in the history
  • Loading branch information
GregorSpagnolo committed Jan 28, 2023
1 parent 6e37ccf commit 054c9ba
Show file tree
Hide file tree
Showing 19 changed files with 138 additions and 138 deletions.
6 changes: 3 additions & 3 deletions src/SecureBank/Ctf/Authorization/CtfAuthorizeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public override bool AuthorizeAdmin(AuthorizationFilterContext context)
{
CtfOptions ctfOptions = context.HttpContext.RequestServices.GetRequiredService<IOptions<CtfOptions>>().Value;

CtfChallangeModel ctfChallange = ctfOptions.CtfChallanges
CtfChallengeModel ctfChallenge = ctfOptions.CtfChallenges
.Where(x => x.Type == CtfChallengeTypes.ChangeRoleInCookie)
.Single();

context.HttpContext.Response.Headers.Add(ctfChallange.FlagKey, ctfChallange.Flag);
context.HttpContext.Response.Headers.Add(ctfChallenge.FlagKey, ctfChallenge.Flag);
}
}
else
Expand All @@ -75,7 +75,7 @@ public override bool AuthorizeMissing(AuthorizationFilterContext context)

if (ctfOptions.CtfChallengeOptions.MissingAuthentication)
{
CtfChallangeModel missingAuth = ctfOptions.CtfChallanges
CtfChallengeModel missingAuth = ctfOptions.CtfChallenges
.Where(x => x.Type == CtfChallengeTypes.MissingAuthentication)
.Single();

Expand Down
34 changes: 17 additions & 17 deletions src/SecureBank/Ctf/CTFd/CTFdExportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public class CTFdExportService
{
private const string ALEMBIC_VERSION_2_2_0 = "080d29b15cd3";

private const int CTFD_CHALLANGE_VALUE = 10;
private const int CTFD_CHALLENGE_VALUE = 10;

private const string CTFD_CHALLANGE_TYPE = "standard";
private const string CTFD_CHALLANGE_STATE = "visible";
private const string CTFD_CHALLENGE_TYPE = "standard";
private const string CTFD_CHALLENGE_STATE = "visible";

private const string CTFD_FLAG_TYPE = "static";

Expand All @@ -38,28 +38,28 @@ private static CTFdBaseModel<CTFdAlembicVersionModel> GetAlembicVersion()
return new CTFdBaseModel<CTFdAlembicVersionModel>(cTFdAlembicVersion);
}

private static CTFdBaseModel<CTFdChallengeModel> GetChallanges(List<CtfChallangeModel> ctfChallanges)
private static CTFdBaseModel<CTFdChallengeModel> GetChallenges(List<CtfChallengeModel> ctfChallenges)
{
List<CTFdChallengeModel> cTFdChallanges = ctfChallanges
List<CTFdChallengeModel> cTFdChallenges = ctfChallenges
.Select(x => new CTFdChallengeModel(
id: (int)x.Type,
name: x.Title,
description: "",
maxAttempts: 0,
value: CTFD_CHALLANGE_VALUE,
value: CTFD_CHALLENGE_VALUE,
category: x.Category.ToString(),
type: CTFD_CHALLANGE_TYPE,
state: CTFD_CHALLANGE_STATE))
type: CTFD_CHALLENGE_TYPE,
state: CTFD_CHALLENGE_STATE))
.ToList();

return new CTFdBaseModel<CTFdChallengeModel>(cTFdChallanges);
return new CTFdBaseModel<CTFdChallengeModel>(cTFdChallenges);
}

private static CTFdBaseModel<CTFdFlagModel> GetFlags(List<CtfChallangeModel> ctfChallanges)
private static CTFdBaseModel<CTFdFlagModel> GetFlags(List<CtfChallengeModel> ctfChallenges)
{
int flagIndex = 1;

List<CTFdFlagModel> cTFdFlags = ctfChallanges
List<CTFdFlagModel> cTFdFlags = ctfChallenges
.Select(x => new CTFdFlagModel(
id: flagIndex++,
challengeId: (int)x.Type,
Expand All @@ -71,7 +71,7 @@ private static CTFdBaseModel<CTFdFlagModel> GetFlags(List<CtfChallangeModel> ctf
return new CTFdBaseModel<CTFdFlagModel>(cTFdFlags);
}

public async Task Export(string path, List<CtfChallangeModel> ctfChallanges)
public async Task Export(string path, List<CtfChallengeModel> ctfChallenges)
{
if (!Directory.Exists(path))
{
Expand All @@ -94,16 +94,16 @@ public async Task Export(string path, List<CtfChallangeModel> ctfChallanges)
CTFdBaseModel<CTFdAlembicVersionModel> alembicVersion = GetAlembicVersion();
await WriteZipDbEntry(zipArchive, ALEMBIC_VERSION_ENTRY_NAME, alembicVersion);

CTFdBaseModel<CTFdChallengeModel> challanges = GetChallanges(ctfChallanges);
await WriteZipDbEntry(zipArchive, CHALLENGES_ENTRY_NAME, challanges);
CTFdBaseModel<CTFdChallengeModel> challenges = GetChallenges(ctfChallenges);
await WriteZipDbEntry(zipArchive, CHALLENGES_ENTRY_NAME, challenges);

CTFdBaseModel<CTFdFlagModel> flags = GetFlags(ctfChallanges);
CTFdBaseModel<CTFdFlagModel> flags = GetFlags(ctfChallenges);
await WriteZipDbEntry(zipArchive, FLAGS_ENTRY_NAME, flags);
}

private static async Task WriteZipDbEntry<T>(ZipArchive zipArchive, string entryName, CTFdBaseModel<T> model)
{
JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings
JsonSerializerSettings jsonSerializeSettings = new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver
{
Expand All @@ -114,7 +114,7 @@ private static async Task WriteZipDbEntry<T>(ZipArchive zipArchive, string entry

using Stream zipStream = zipArchive.CreateEntry(entryName, CompressionLevel.Fastest).Open();

string json = JsonConvert.SerializeObject(model, jsonSerializerSettings);
string json = JsonConvert.SerializeObject(model, jsonSerializeSettings);
byte[] data = Encoding.UTF8.GetBytes(json);

await zipStream.WriteAsync(data);
Expand Down
Loading

0 comments on commit 054c9ba

Please sign in to comment.