Skip to content

Commit 96a256f

Browse files
committed
Fix can't find protections
1 parent 0bb5ffd commit 96a256f

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/BitMono.CLI/Modules/OptionsObfuscationNeedsFactory.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public OptionsObfuscationNeedsFactory(string[] args)
6969
var fileBaseDirectory = Path.GetDirectoryName(filePath);
7070

7171
ProtectionSettings? protectionSettings = null;
72+
string? protectionsFile = options.ProtectionsFile;
7273
if (options.Protections.Any())
7374
{
7475
protectionSettings = new ProtectionSettings
@@ -80,6 +81,27 @@ public OptionsObfuscationNeedsFactory(string[] args)
8081
}).ToList()
8182
};
8283
}
84+
else
85+
{
86+
// Try to find protections.json for fallback
87+
if (protectionsFile != null && File.Exists(protectionsFile))
88+
{
89+
// Use specified file
90+
}
91+
else if (File.Exists(KnownConfigNames.Protections))
92+
{
93+
protectionsFile = KnownConfigNames.Protections;
94+
}
95+
else
96+
{
97+
// Fallback to application base directory
98+
var baseProtectionsFile = Path.Combine(AppContext.BaseDirectory, KnownConfigNames.Protections);
99+
if (File.Exists(baseProtectionsFile))
100+
{
101+
protectionsFile = baseProtectionsFile;
102+
}
103+
}
104+
}
83105

84106
ObfuscationNeeds needs;
85107
if (obfuscationSettings?.ForceObfuscation == true)
@@ -96,7 +118,7 @@ public OptionsObfuscationNeedsFactory(string[] args)
96118
CriticalsFile = options.CriticalsFile,
97119
LoggingFile = options.LoggingFile,
98120
ObfuscationFile = options.ObfuscationFile,
99-
ProtectionsFile = options.ProtectionsFile,
121+
ProtectionsFile = protectionsFile,
100122
ObfuscationSettings = obfuscationSettings
101123
};
102124
}
@@ -118,7 +140,7 @@ public OptionsObfuscationNeedsFactory(string[] args)
118140
CriticalsFile = options.CriticalsFile,
119141
LoggingFile = options.LoggingFile,
120142
ObfuscationFile = options.ObfuscationFile,
121-
ProtectionsFile = options.ProtectionsFile,
143+
ProtectionsFile = protectionsFile,
122144
ObfuscationSettings = obfuscationSettings
123145
};
124146
}

src/BitMono.Shared/Models/ProtectionSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ namespace BitMono.Shared.Models;
22

33
public class ProtectionSettings
44
{
5-
public List<ProtectionSetting>? Protections { get; set; }
5+
public List<ProtectionSetting> Protections { get; set; } = [];
66
}

0 commit comments

Comments
 (0)