Skip to content

Commit

Permalink
fix(backedn): add NPOI lib
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Apr 21, 2024
1 parent 2d046b5 commit c4b20ee
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \

WORKDIR /app
EXPOSE 8080
RUN apk add --no-cache wget libpcap icu-data-full icu-libs ca-certificates && \
RUN apk add --update --no-cache wget libpcap icu-data-full icu-libs ca-certificates libgdiplus && \
update-ca-certificates

COPY --from=publish /app/publish .
Expand Down
3 changes: 2 additions & 1 deletion src/GZCTF/Controllers/ProxyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ public async Task<IActionResult> ProxyForNoInstance(Guid id, CancellationToken t
catch (SocketException e)
{
logger.SystemLog(
Program.StaticLocalizer[nameof(Resources.Program.Proxy_ContainerConnectionFailedLog), e.SocketErrorCode,
Program.StaticLocalizer[nameof(Resources.Program.Proxy_ContainerConnectionFailedLog),
e.SocketErrorCode,
$"{target.Address}:{target.Port}"],
TaskStatus.Failed, LogLevel.Debug);
return new JsonResult(new RequestResponse(
Expand Down
4 changes: 2 additions & 2 deletions src/GZCTF/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy AS build
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS build
ARG TARGETPLATFORM
COPY publish /build
RUN cp -r /build/${TARGETPLATFORM} /publish
Expand All @@ -10,7 +10,7 @@ ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \

WORKDIR /app
EXPOSE 8080
RUN apk add --no-cache wget libpcap icu-data-full icu-libs ca-certificates && \
RUN apk add --update --no-cache wget libpcap icu-data-full icu-libs ca-certificates libgdiplus && \
update-ca-certificates

COPY --from=build /publish .
Expand Down
8 changes: 4 additions & 4 deletions src/GZCTF/Extensions/TelemetryExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ public static void UseTelemetry(this IApplicationBuilder app, TelemetryConfig? c
app.UseOpenTelemetryPrometheusScrapingEndpoint(context =>
{
if (string.Equals(
context.Request.Path.ToString().TrimEnd('/'),
"/metrics",
StringComparison.OrdinalIgnoreCase))
context.Request.Path.ToString().TrimEnd('/'),
"/metrics",
StringComparison.OrdinalIgnoreCase))
{
// FIXME: workaround for prometheus
context.Request.Headers.Accept = "application/openmetrics-text";
Expand All @@ -105,4 +105,4 @@ public static void UseTelemetry(this IApplicationBuilder app, TelemetryConfig? c
return false;
});
}
}
}
3 changes: 2 additions & 1 deletion src/GZCTF/Services/Cache/CacheMaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public async Task StartAsync(CancellationToken token)

#endregion

await Task.Factory.StartNew(() => Maker(TokenSource.Token), token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
await Task.Factory.StartNew(() => Maker(TokenSource.Token), token, TaskCreationOptions.LongRunning,
TaskScheduler.Default);
}

public Task StopAsync(CancellationToken token)
Expand Down
3 changes: 2 additions & 1 deletion src/GZCTF/Services/FlagChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public async Task StartAsync(CancellationToken cancellationToken)
TokenSource = new CancellationTokenSource();

for (var i = 0; i < 2; ++i)
await Task.Factory.StartNew(() => Checker(i, TokenSource.Token), cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default);
await Task.Factory.StartNew(() => Checker(i, TokenSource.Token), cancellationToken,
TaskCreationOptions.LongRunning, TaskScheduler.Default);

await using AsyncServiceScope scope = serviceScopeFactory.CreateAsyncScope();

Expand Down
4 changes: 3 additions & 1 deletion src/GZCTF/Services/MailSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ public sealed class MailSender : IMailSender, IDisposable
{
var cipherName = cipher.ToString();
// Exclude MD5, SHA1, and NULL ciphers for security reasons
return !cipherName.EndsWith("MD5") && !cipherName.EndsWith("SHA") && !cipherName.EndsWith("NULL");
return !cipherName.EndsWith("MD5") && !cipherName.EndsWith("SHA") &&
!cipherName.EndsWith("NULL");
}));
}

Task.Factory.StartNew(MailSenderWorker, _cancellationToken, TaskCreationOptions.LongRunning,
TaskScheduler.Default);
}
Expand Down
14 changes: 8 additions & 6 deletions src/GZCTF/Utils/ExcelHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public MemoryStream GetSubmissionExcel(IEnumerable<Submission> submissions)
return stream;
}

ICellStyle GetHeaderStyle(XSSFWorkbook workbook)
static ICellStyle GetHeaderStyle(XSSFWorkbook workbook)
{
ICellStyle? style = workbook.CreateCellStyle();
IFont? boldFontStyle = workbook.CreateFont();
Expand Down Expand Up @@ -139,7 +139,7 @@ int[] WriteBoardHeader(ISheet sheet, ICellStyle style, ScoreboardModel scoreboar
return challIds.ToArray();
}

void WriteBoardContent(ISheet sheet, ScoreboardModel scoreboard, int[] challIds, Game game)
static void WriteBoardContent(ISheet sheet, ScoreboardModel scoreboard, int[] challIds, Game game)
{
var rowIndex = 1;
var withOrg = game.Organizations is not null && game.Organizations.Count > 0;
Expand All @@ -154,11 +154,13 @@ void WriteBoardContent(ISheet sheet, ScoreboardModel scoreboard, int[] challIds,
if (withOrg)
row.CreateCell(colIndex++).SetCellValue(item.Organization);

row.CreateCell(colIndex++).SetCellValue(item.TeamInfo!.Captain!.RealName);
row.CreateCell(colIndex++).SetCellValue(string.Join("/", item.TeamInfo!.Members.Select(m => m.RealName)));
row.CreateCell(colIndex++).SetCellValue(string.Join("/", item.TeamInfo!.Members.Select(m => m.StdNumber)));
row.CreateCell(colIndex++).SetCellValue(item.TeamInfo?.Captain?.RealName ?? string.Empty);
row.CreateCell(colIndex++)
.SetCellValue(string.Join("/", item.TeamInfo!.Members.Select(m => m.PhoneNumber)));
.SetCellValue(string.Join("/", item.TeamInfo?.Members.Select(m => m.RealName) ?? []));
row.CreateCell(colIndex++)
.SetCellValue(string.Join("/", item.TeamInfo?.Members.Select(m => m.StdNumber) ?? []));
row.CreateCell(colIndex++)
.SetCellValue(string.Join("/", item.TeamInfo?.Members.Select(m => m.PhoneNumber) ?? []));

row.CreateCell(colIndex++).SetCellValue(item.SolvedCount);
row.CreateCell(colIndex++).SetCellValue(item.LastSubmissionTime.ToString("u"));
Expand Down
2 changes: 1 addition & 1 deletion src/GZCTF/Utils/RecordableNetworkStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ protected override void Dispose(bool disposing)

_disposed = true;
}
}
}

0 comments on commit c4b20ee

Please sign in to comment.