From 6f25ab9bb1884d07894956ebab92f8e47c83b315 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Thu, 1 May 2025 07:44:21 -0400 Subject: [PATCH 1/5] Future AppImage support --- AppDir/s2pk.desktop | 7 +++++++ Makefile | 9 ++++++++- S2PK.csproj | 1 + appimage-builder.yml | 18 ++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 AppDir/s2pk.desktop create mode 100644 appimage-builder.yml diff --git a/AppDir/s2pk.desktop b/AppDir/s2pk.desktop new file mode 100644 index 0000000..c92b910 --- /dev/null +++ b/AppDir/s2pk.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=s2pk +Exec=s2pk +Icon=s2pk +Type=Application +Categories=Utility; +Terminal=true diff --git a/Makefile b/Makefile index f3f883a..6c523d7 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,9 @@ CONFIGURATION = Release RUNTIME_LINUX = linux-x64 RUNTIME_MAC = osx-x64 OUTPUT_DIR = ./dist +APPIMAGE_DIR = ./AppDir -.PHONY: all clean build-linux build-mac package-linux package-mac +.PHONY: all clean build-linux build-mac build-appimage package-linux package-mac package-appimage all: build-linux build-mac package-linux package-mac @@ -16,6 +17,9 @@ clean: build-linux: dotnet publish -c $(CONFIGURATION) -r $(RUNTIME_LINUX) --self-contained true /p:PublishSingleFile=true -o $(OUTPUT_DIR)/$(APP_NAME)-linux +build-appimage: + dotnet publish -c $(CONFIGURATION) -r $(RUNTIME_LINUX) --self-contained true /p:PublishSingleFile=true -o $(APPIMAGE_DIR)/usr/bin + build-mac: dotnet publish -c $(CONFIGURATION) -r $(RUNTIME_MAC) --self-contained true /p:PublishSingleFile=true -o $(OUTPUT_DIR)/$(APP_NAME)-mac @@ -24,3 +28,6 @@ package-linux: package-mac: tar -czvf $(OUTPUT_DIR)/$(APP_NAME)-mac.tar.gz -C $(OUTPUT_DIR)/$(APP_NAME)-mac . + +package-appimage: + appimage-builder diff --git a/S2PK.csproj b/S2PK.csproj index 9adff19..bfe7c8e 100644 --- a/S2PK.csproj +++ b/S2PK.csproj @@ -8,6 +8,7 @@ enable Tony Bark true + s2pk s2pk s2pk diff --git a/appimage-builder.yml b/appimage-builder.yml new file mode 100644 index 0000000..1b4151c --- /dev/null +++ b/appimage-builder.yml @@ -0,0 +1,18 @@ +version: 1 +AppDir: + path: ./AppDir + app_info: + id: com.tonybark.s2pk + name: s2pk + icon: s2pk + version: 0.3.101 + exec: usr/bin/s2pk + exec_args: "" + runtime: + env: + PATH: "$APPDIR/usr/bin:$PATH" + +recipe: + AppImage: + arch: x86_64 + output: s2pk-x86_64.AppImage From 55d89f835be94f7146f4184766c2b9fd7283507c Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Thu, 1 May 2025 08:48:26 -0400 Subject: [PATCH 2/5] Monthly Vulnerability Scan --- .../workflows/monthly-vulnerability-scan.yml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/monthly-vulnerability-scan.yml diff --git a/.github/workflows/monthly-vulnerability-scan.yml b/.github/workflows/monthly-vulnerability-scan.yml new file mode 100644 index 0000000..eea0819 --- /dev/null +++ b/.github/workflows/monthly-vulnerability-scan.yml @@ -0,0 +1,27 @@ +# .github/workflows/monthly-vulnerability-scan.yml +name: Monthly Vulnerability Scan + +on: + schedule: + - cron: "0 0 1 * *" # Runs at 00:00 on the 1st day of every month + workflow_dispatch: # Allows manual triggering + +jobs: + scan-vulnerabilities: + name: Scan for .NET Package Vulnerabilities + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: "8.0.x" # Match latest LTS or adjust as needed + + - name: Restore dependencies + run: dotnet restore + + - name: List vulnerable packages + run: dotnet list package --vulnerable From dfe83fcf009ffa68be5c7750487abdaf144d2af3 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Thu, 1 May 2025 08:59:53 -0400 Subject: [PATCH 3/5] Minor tweak to CI --- .github/workflows/monthly-vulnerability-scan.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/monthly-vulnerability-scan.yml b/.github/workflows/monthly-vulnerability-scan.yml index eea0819..1a90968 100644 --- a/.github/workflows/monthly-vulnerability-scan.yml +++ b/.github/workflows/monthly-vulnerability-scan.yml @@ -1,4 +1,3 @@ -# .github/workflows/monthly-vulnerability-scan.yml name: Monthly Vulnerability Scan on: @@ -24,4 +23,11 @@ jobs: run: dotnet restore - name: List vulnerable packages - run: dotnet list package --vulnerable + run: | + set -e + results=$(dotnet list package --vulnerable) + echo "$results" + if echo "$results" | grep -q "has the following vulnerable packages"; then + echo "Vulnerabilities found!" + exit 1 + fi From 9af646b53442c06b1137c37aebe1e9c1ac4f295b Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Thu, 1 May 2025 09:03:05 -0400 Subject: [PATCH 4/5] Fixed oversight in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d90dea9..c062058 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ While The Sims 2 runs well on Linux through Wine, especially with Lutris setups, - .NET 8.0 - C# (focused on clarity, safety, minimalism) -- System.CommandLine for CLI parsing (no external libraries) +- System.CommandLine for CLI parsing - Pure backend logic (no UI planned) ## 📐 Design Principles From d7e477c4ddc8589df3bb30023edb59ae3d2e5ef3 Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Thu, 1 May 2025 09:27:58 -0400 Subject: [PATCH 5/5] Serilog integration --- AppDir/s2pk.desktop | 4 ++-- GlobalUsing.cs | 3 +++ PackageManger.cs | 14 +++++++------- Program.cs | 8 ++++++++ README.md | 2 +- S2PK.csproj | 3 +++ 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/AppDir/s2pk.desktop b/AppDir/s2pk.desktop index c92b910..caf5609 100644 --- a/AppDir/s2pk.desktop +++ b/AppDir/s2pk.desktop @@ -1,7 +1,7 @@ [Desktop Entry] -Name=s2pk +Name=Sims 2 Package Manager Exec=s2pk -Icon=s2pk +Icon=logo.svg Type=Application Categories=Utility; Terminal=true diff --git a/GlobalUsing.cs b/GlobalUsing.cs index 800695e..7ea0ebc 100644 --- a/GlobalUsing.cs +++ b/GlobalUsing.cs @@ -1,2 +1,5 @@ global using S2PK; global using Tomlyn; +global using Serilog; +global using Serilog.Sinks.Debug; +global using Serilog.Sinks.Console; diff --git a/PackageManger.cs b/PackageManger.cs index ace0601..6a6a9bf 100644 --- a/PackageManger.cs +++ b/PackageManger.cs @@ -28,14 +28,14 @@ public static class PackageManager if (!dir.Exists) { - Console.Error.WriteLine("Source directory does not exist."); + Log.Error("Source directory does not exist."); return; } var packageFiles = dir.GetFiles($"*{PackageExtension}", SearchOption.AllDirectories); if (packageFiles.Length == 0) { - Console.Error.WriteLine("No .package files found to pack."); + Log.Error("No .package files found to pack."); return; } @@ -75,7 +75,7 @@ public static class PackageManager // Check if destination directory exists if (!Directory.Exists(destination)) { - Console.Error.WriteLine("Destination directory does not exist."); + Log.Error("Destination directory does not exist."); return; } @@ -85,21 +85,21 @@ public static class PackageManager if (!file.Exists) { - Console.Error.WriteLine("Package file does not exist."); + Log.Error("Package file does not exist."); return; } if (!file.FullName.Contains(extension)) { - Console.Error.WriteLine("Package file is not a valid."); + Log.Error("Package file is not a valid."); return; } // Check for extension mismatch if (file.FullName.Contains(S3pkExtension) && !ts3) { - Console.Error.WriteLine("Package is for The Sims 3 but unpacking for The Sims 2."); + Log.Error("Package is for The Sims 3 but unpacking for The Sims 2."); return; } @@ -113,7 +113,7 @@ public static class PackageManager // Sanitize path to prevent directory traversal if (!fullPath.StartsWith(dir.FullName, StringComparison.OrdinalIgnoreCase)) { - Console.Error.WriteLine($"Skipping unsafe path: {entry.FullName}"); + Log.Error($"Skipping unsafe path: {entry.FullName}"); continue; } diff --git a/Program.cs b/Program.cs index 6ab3c17..b1d5114 100644 --- a/Program.cs +++ b/Program.cs @@ -2,6 +2,14 @@ using System.CommandLine; var rootCommand = new RootCommand("The Sims 2 .s2pk Package Manager"); +Log.Logger = new LoggerConfiguration() +#if DEBUG + .WriteTo.Debug() +#else + .WriteTo.Console(theme: AnsiConsoleTheme.Code) +#endif + .CreateLogger(); + var sims3option = new Option( aliases: ["--ts3"], description: "Switch to The Sims 3 mode.", diff --git a/README.md b/README.md index c062058..99dd98d 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ While The Sims 2 runs well on Linux through Wine, especially with Lutris setups, | ----- | ------------------------------------------- | ------ | | v0.1 | Core package manager | ✅ | | v0.2 | Config file with default paths | ✅ | -| v0.3 | Sims 3 support with `s3pk` extention | 🔜 | +| v0.3 | Sims 3 support with `s3pk` extension | 🔜 | | v0.x | Target .NET 10 | 🔜 | | v1.0 | Stable "Release" version with documentation | 🔜 | diff --git a/S2PK.csproj b/S2PK.csproj index bfe7c8e..54402e0 100644 --- a/S2PK.csproj +++ b/S2PK.csproj @@ -14,6 +14,9 @@ + + +