Skip to content

Commit 17e343c

Browse files
authored
Merge pull request #29 from sunnamed434/dev
Changelog fix + deprecated protections notifying
2 parents c24784b + 3b55cf8 commit 17e343c

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

BitMono/BitMono.Obfuscation/ProtectionsExecutionNotifier.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,25 @@ public ProtectionsExecutionNotifier(ILogger logger)
1515

1616
public Task NotifyAsync(ProtectionsSortingResult protectionsSortingResult)
1717
{
18+
if (protectionsSortingResult.DeprecatedProtections.Any())
19+
{
20+
m_Logger.Warning("Deprecated protections which shouldn`t be used anymore: {0}", string.Join(", ", protectionsSortingResult.DeprecatedProtections.Select(p => p?.GetType()?.Name ?? "NULL")));
21+
}
1822
if (protectionsSortingResult.Skipped.Any())
1923
{
20-
m_Logger.Warning("Skip protections: {0}", string.Join(", ", protectionsSortingResult.Skipped.Select(p => p ?? "NULL")));
24+
m_Logger.Warning("Skip protections: {0}", string.Join(", ", protectionsSortingResult.Skipped.Select(p => p?.GetType()?.Name ?? "NULL")));
2125
}
2226
if (protectionsSortingResult.ObfuscationAttributeExcludingProtections.Any())
2327
{
24-
m_Logger.Warning("Skip protections with obfuscation attribute excluding: {0}", string.Join(", ", protectionsSortingResult.ObfuscationAttributeExcludingProtections.Select(p => p.GetType().Name ?? "NULL")));
28+
m_Logger.Warning("Skip protections with obfuscation attribute excluding: {0}", string.Join(", ", protectionsSortingResult.ObfuscationAttributeExcludingProtections.Select(p => p?.GetType()?.Name ?? "NULL")));
2529
}
2630
if (protectionsSortingResult.Protections.Any())
2731
{
28-
m_Logger.Information("Execute protections: {0}", string.Join(", ", protectionsSortingResult.Protections.Select(p => p.GetType().Name ?? "NULL")));
32+
m_Logger.Information("Execute protections: {0}", string.Join(", ", protectionsSortingResult.Protections.Select(p => p?.GetType()?.Name ?? "NULL")));
2933
}
3034
if (protectionsSortingResult.StageProtections.Any())
3135
{
32-
m_Logger.Information("Execute calling condition protections: {0}", string.Join(", ", protectionsSortingResult.StageProtections.Select(p => p.GetType().Name ?? "NULL")));
36+
m_Logger.Information("Execute calling condition protections: {0}", string.Join(", ", protectionsSortingResult.StageProtections.Select(p => p?.GetType()?.Name ?? "NULL")));
3337
}
3438
return Task.CompletedTask;
3539
}

BitMono/BitMono.Obfuscation/ProtectionsSorter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
using BitMono.Core.Models;
55
using BitMono.Core.Protecting.Resolvers;
66
using dnlib.DotNet;
7+
using System;
78
using System.Collections.Generic;
89
using System.Linq;
10+
using System.Reflection;
911
using System.Threading.Tasks;
1012
using ILogger = Serilog.ILogger;
1113

@@ -31,6 +33,7 @@ public Task<ProtectionsSortingResult> SortAsync(ICollection<IProtection> protect
3133
{
3234
protections = new DependencyResolver(protections, protectionSettings, m_Logger)
3335
.Sort(out ICollection<string> skipped);
36+
var deprecatedProtections = protections.Where(p => p.GetType().GetCustomAttribute<ObsoleteAttribute>(false) != null);
3437
var stageProtections = protections.Where(p => p is IStageProtection).Cast<IStageProtection>();
3538
var pipelineProtections = protections.Where(p => p is IPipelineProtection).Cast<IPipelineProtection>();
3639
var obfuscationAttributeExcludingProtections = protections.Where(p =>
@@ -41,6 +44,7 @@ public Task<ProtectionsSortingResult> SortAsync(ICollection<IProtection> protect
4144
return Task.FromResult(new ProtectionsSortingResult
4245
{
4346
Protections = protections,
47+
DeprecatedProtections = deprecatedProtections,
4448
Skipped = skipped,
4549
StageProtections = stageProtections,
4650
PipelineProtections = pipelineProtections,

BitMono/BitMono.Obfuscation/ProtectionsSortingResult.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace BitMono.Obfuscation
77
public class ProtectionsSortingResult
88
{
99
public ICollection<IProtection> Protections { get; set; }
10+
public IEnumerable<IProtection> DeprecatedProtections { get; set; }
1011
public ICollection<string> Skipped { get; set; }
1112
public IEnumerable<IStageProtection> StageProtections { get; set; }
1213
public IEnumerable<IPipelineProtection> PipelineProtections { get; set; }

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Feature that allows to protect types/methods with the specified namespace in obfuscation.json configuration [#27](https://github.com/sunnamed434/BitMono/issues/27)
1515

1616
### Changed:
17-
* FieldsHiding protection currently is currently deprecated and shouldn`t be used anymore
17+
* FieldsHiding protection currently is deprecated and shouldn`t be used anymore
1818

1919
#### Fixed:
2020
* AntiDebugBreakpoints Protection

0 commit comments

Comments
 (0)