diff --git a/.github/workflows/release-obfuscator-common.yml b/.github/workflows/release-obfuscator-common.yml
index 5e018ca..9567293 100644
--- a/.github/workflows/release-obfuscator-common.yml
+++ b/.github/workflows/release-obfuscator-common.yml
@@ -25,7 +25,9 @@ jobs:
- name: dotnet pack
run: dotnet pack -c Release 'src/${{ env.PROJECT }}/${{ env.PROJECT }}.csproj'
- name: nuget push
- run: echo "::warning::(TOFIX) enable nuget push."
+ run: dotnet nuget push '${{ env.NUPKG_PATH }}' -k '${{ secrets.NUGET_API_KEY }}' -s https://api.nuget.org/v3/index.json
+ env:
+ NUPKG_PATH: 'src/artifacts/package/release/${{ env.PROJECT }}.${{ steps.nbgv.outputs.NuGetPackageVersion }}.nupkg'
- name: create release
run: |
PRERELEASE_FLAG=$([[ "${{ steps.nbgv.outputs.PrereleaseVersion }}" != "" ]] && echo "--prerelease" || echo "")
diff --git a/src/Dax.Vpax.Obfuscator.Common/Dax.Vpax.Obfuscator.Common.csproj b/src/Dax.Vpax.Obfuscator.Common/Dax.Vpax.Obfuscator.Common.csproj
index bbabb82..24a67d0 100644
--- a/src/Dax.Vpax.Obfuscator.Common/Dax.Vpax.Obfuscator.Common.csproj
+++ b/src/Dax.Vpax.Obfuscator.Common/Dax.Vpax.Obfuscator.Common.csproj
@@ -2,12 +2,12 @@
netstandard2.0
- false
+ true
Vpax Obfuscator Common
- A shared package used by VertiPaq Analyzer Obfuscator. Do not install this package manually, it will be added as a prerequisite by other packages that require it.
+ This package is a dependency for the VertiPaq Analyzer Obfuscator NuGet package and is automatically included as a prerequisite. It should not be installed manually.
diff --git a/src/Dax.Vpax.Obfuscator.Common/ObfuscationDictionary.cs b/src/Dax.Vpax.Obfuscator.Common/ObfuscationDictionary.cs
index f87a9c3..4a7f94f 100644
--- a/src/Dax.Vpax.Obfuscator.Common/ObfuscationDictionary.cs
+++ b/src/Dax.Vpax.Obfuscator.Common/ObfuscationDictionary.cs
@@ -1,4 +1,5 @@
-using System.Text;
+using System.Diagnostics.CodeAnalysis;
+using System.Text;
using Newtonsoft.Json;
namespace Dax.Vpax.Obfuscator.Common;
@@ -26,8 +27,9 @@ public ObfuscationDictionary(string id, string version, IEnumerable t.Value).ToArray();
+ UnobfuscatedValues = Array.Empty();
- // Create dictionaries to allow for fast lookups. This also ensures uniqueness of the keys by throwing if there are duplicates.
+ // Create dictionaries to enable fast lookups and ensure key uniqueness. An error will be thrown if duplicate keys are detected.
_values = Texts.ToDictionary((text) => text.Value, StringComparer.OrdinalIgnoreCase);
_obfuscated = Texts.ToDictionary((text) => text.Obfuscated, StringComparer.OrdinalIgnoreCase);
}
@@ -35,7 +37,7 @@ public ObfuscationDictionary(string id, string version, IEnumerable Texts { get; }
- public IReadOnlyList? UnobfuscatedValues { get; }
+ public IReadOnlyList UnobfuscatedValues { get; }
public string GetValue(string obfuscated)
{
@@ -45,6 +47,18 @@ public string GetValue(string obfuscated)
throw new KeyNotFoundException($"The obfuscated value was not found in the dictionary [{obfuscated}].");
}
+ public bool TryGetValue(string obfuscated, [NotNullWhen(true)] out string? value)
+ {
+ if (_obfuscated.TryGetValue(obfuscated, out var text))
+ {
+ value = text.Value;
+ return true;
+ }
+
+ value = null;
+ return false;
+ }
+
public string GetObfuscated(string value)
{
if (_values.TryGetValue(value, out var text))
@@ -53,6 +67,18 @@ public string GetObfuscated(string value)
throw new KeyNotFoundException($"The value was not found in the dictionary [{value}].");
}
+ public bool TryGetObfuscated(string value, [NotNullWhen(true)] out string? obfuscated)
+ {
+ if (_values.TryGetValue(value, out var text))
+ {
+ obfuscated = text.Obfuscated;
+ return true;
+ }
+
+ obfuscated = null;
+ return false;
+ }
+
public void WriteTo(string path, bool overwrite = false, bool indented = true)
{
var mode = overwrite ? FileMode.Create : FileMode.CreateNew;
diff --git a/src/Dax.Vpax.Obfuscator.TestApp/Form1.cs b/src/Dax.Vpax.Obfuscator.TestApp/Form1.cs
index 2a95679..5f200f4 100644
--- a/src/Dax.Vpax.Obfuscator.TestApp/Form1.cs
+++ b/src/Dax.Vpax.Obfuscator.TestApp/Form1.cs
@@ -108,22 +108,22 @@ private static void Obfuscate(FileInfo vpaxFile, FileInfo? dictionaryFile, strin
: obfuscator.Obfuscate(stream);
var dictionaryPath = Path.Combine(outputPath, Path.ChangeExtension(vpaxFile.Name, ".vpax.dict"));
- var vpaxPath = Path.Combine(outputPath, Path.ChangeExtension(vpaxFile.Name, ".obfuscated.vpax"));
+ var ovpaxPath = Path.Combine(outputPath, Path.ChangeExtension(vpaxFile.Name, ".ovpax"));
dictionary.WriteTo(dictionaryPath, overwrite, indented: true);
- File.WriteAllBytes(vpaxPath, stream.ToArray());
+ File.WriteAllBytes(ovpaxPath, stream.ToArray());
}
- private static void Deobfuscate(FileInfo vpaxFile, FileInfo dictionaryFile)
+ private static void Deobfuscate(FileInfo ovpaxFile, FileInfo dictionaryFile)
{
- var data = File.ReadAllBytes(vpaxFile.FullName);
+ var data = File.ReadAllBytes(ovpaxFile.FullName);
using var stream = new MemoryStream();
stream.Write(data, 0, data.Length);
var obfuscator = new VpaxObfuscator();
obfuscator.Deobfuscate(stream, ObfuscationDictionary.ReadFrom(dictionaryFile.FullName));
- var vpaxPath = Path.Combine(vpaxFile.DirectoryName!, Path.ChangeExtension(vpaxFile.Name, ".deobfuscated.vpax"));
+ var vpaxPath = Path.Combine(ovpaxFile.DirectoryName!, Path.ChangeExtension(ovpaxFile.Name, ".deobfuscated.vpax"));
File.WriteAllBytes(vpaxPath, stream.ToArray());
}
}