-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish trimmed into docker image, use noble-chiseled base image, min…
…or refactoring
- Loading branch information
Showing
16 changed files
with
144 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace CrackSharp.Api.Common; | ||
|
||
[JsonSerializable(typeof(HttpValidationProblemDetails))] | ||
internal partial class AppJsonSerializerContext : JsonSerializerContext | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,73 @@ | ||
@CrackSharp.Api_HostAddress = https://localhost:5001 | ||
@CrackSharp_Api_HostAddress = http://localhost:5000 | ||
|
||
GET {{CrackSharp.Api_HostAddress}}/api/v1/des/decrypt/FAzlTwVAZ1NZ2 | ||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/decrypt/FAzlTwVAZ1NZ2 | ||
|
||
### 200 "LOL" | ||
|
||
GET {{CrackSharp.Api_HostAddress}}/api/v1/des/decrypt/FAzlTwVAZ1NZ2?chars=LMNO&maxTextLength=4 | ||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/decrypt/FAzlTwVAZ1NZ2?chars=LMNO&maxTextLength=4 | ||
|
||
### 200 "LOL" | ||
|
||
GET {{CrackSharp.Api_HostAddress}}/api/v1/des/encrypt/abc | ||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/decrypt/FAzlTwVAZ1NZ2?chars=LMNO | ||
|
||
### 200 "LOL" | ||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/decrypt/FAzlTwVAZ1NZ2?maxTextLength=4 | ||
|
||
### 200 "LOL" | ||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/encrypt/abc | ||
|
||
### 200 DES hash based on random salt | ||
|
||
GET {{CrackSharp.Api_HostAddress}}/api/v1/des/encrypt/abc?salt=50 | ||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/encrypt/abc?salt=50 | ||
|
||
### 200 "50PaJ4.RO0YUo" | ||
|
||
|
||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/decrypt | ||
|
||
### 400 "Required parameter "string hash" was not provided from route or query string." | ||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/decrypt/FAzlTwVAZ1NZ | ||
|
||
### 400 "hash": [ "Value cannot be null or empty and must follow pattern ^[./0-9A-Za-z]{13}$" ] | ||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/decrypt/FAzlTwVAZ1NZ2?maxTextLength=9 | ||
|
||
### 400 "maxTextLength": [ "Value must be greater than 0 and less than 9." ] | ||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/decrypt/FAzlTwVAZ1NZ2?chars=-_ | ||
|
||
### 400 "chars": [ "Value cannot be null or empty and must follow pattern ^[./0-9A-Za-z]+$" ] | ||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/decrypt/FAzlTwVAZ1NZ?maxTextLength=9&chars=-_ | ||
|
||
### 400 Multiple error messages for parameters | ||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/encrypt | ||
|
||
### 400 Required parameter "string text" was not provided from route or query string. | ||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/encrypt/-_ | ||
|
||
### 400 "text": [ "Value cannot be null or empty and must follow pattern ^[./0-9A-Za-z]+$" ] | ||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/encrypt/abc?salt=_ | ||
|
||
### 400 "salt": [ "Value must follow pattern ^[./0-9A-Za-z]{2}$" ] | ||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/encrypt/abc?salt=def | ||
|
||
### 400 "salt": [ "Value must follow pattern ^[./0-9A-Za-z]{2}$" ] | ||
|
||
|
||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/decrypt/FAzlTwVAZ1NZ2?maxTextLength=2 | ||
|
||
### 404 Not Found | ||
|
||
GET {{CrackSharp_Api_HostAddress}}/api/v1/des/decrypt/FAzlTwVAZ1NZ2?chars=L | ||
|
||
### 404 Not Found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace CrackSharp.Api.Des.Model; | ||
namespace CrackSharp.Api.Des.Model; | ||
|
||
public readonly record struct DesDecryptRequest( | ||
[RegularExpression("^[./0-9A-Za-z]{13}$")] string Hash, | ||
[Range(1, 8)] int MaxTextLength = 8, | ||
[RegularExpression("^[./0-9A-Za-z]+$")] string Chars = DesConstants.DecryptDefaultChars); | ||
string Hash, | ||
int MaxTextLength = 8, | ||
string Chars = DesConstants.DecryptDefaultChars); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
using CrackSharp.Api.Des.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace CrackSharp.Api.Des.Model; | ||
|
||
public readonly struct DesDecryptServices | ||
{ | ||
[FromServices] | ||
public required DesBruteForceDecryptionService DecryptionService { get; init; } | ||
|
||
[FromServices] | ||
public required ILogger<DesDecryptServices> Logger { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace CrackSharp.Api.Des.Model; | ||
namespace CrackSharp.Api.Des.Model; | ||
|
||
public readonly record struct DesEncryptRequest( | ||
[RegularExpression("^[./0-9A-Za-z]+$")] string Text, | ||
[RegularExpression("^[./0-9A-Za-z]{2}$")] string? Salt = null); | ||
string Text, | ||
string? Salt = null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
using CrackSharp.Api.Des.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace CrackSharp.Api.Des.Model; | ||
|
||
public readonly struct DesEncryptServices | ||
{ | ||
[FromServices] | ||
public required DesEncryptionService EncryptionService { get; init; } | ||
|
||
[FromServices] | ||
public required ILogger<DesEncryptServices> Logger { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
# Use SDK image | ||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build | ||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-noble AS build | ||
ARG TARGETARCH | ||
ARG BINARY_VERSION | ||
WORKDIR /source | ||
|
||
# Copy csproj and restore as distinct layers | ||
COPY CrackSharp.Core/*.csproj CrackSharp.Core/ | ||
COPY CrackSharp.Api/*.csproj CrackSharp.Api/ | ||
RUN dotnet restore CrackSharp.Api -a $TARGETARCH | ||
|
||
# Copy everything and build the app | ||
# Copy everything and publish the app | ||
COPY CrackSharp.Core/. CrackSharp.Core/ | ||
COPY CrackSharp.Api/. CrackSharp.Api/ | ||
ARG BINARY_VERSION | ||
RUN (echo "$BINARY_VERSION" | grep -Eq "^[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9.]+)?$") && \ | ||
dotnet publish CrackSharp.Api --no-restore -a $TARGETARCH -o /app -p:Version=$BINARY_VERSION || \ | ||
dotnet publish CrackSharp.Api --no-restore -a $TARGETARCH -o /app | ||
dotnet publish CrackSharp.Api -a $TARGETARCH -o /app -p:Version=$BINARY_VERSION || \ | ||
dotnet publish CrackSharp.Api -a $TARGETARCH -o /app | ||
|
||
# Use runtime image | ||
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled | ||
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-noble-chiseled | ||
WORKDIR /app | ||
|
||
# Copy build results and run the app | ||
COPY --from=build /app . | ||
USER $APP_UID | ||
ENTRYPOINT ["./CrackSharp.Api"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,15 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:55053", | ||
"sslPort": 44367 | ||
} | ||
}, | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"CrackSharp.Api": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"applicationUrl": "https://localhost:5001;http://localhost:5000", | ||
"applicationUrl": "http://localhost:5000", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.