From b8d0db995b0f4223b8b474a05d0252ee810471fd Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 4 Sep 2014 22:08:07 -0500 Subject: [PATCH] Added logging for security audits. --- core/features/AEFeature.java | 2 +- me/GridConnection.java | 11 +++++++++++ util/Platform.java | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/features/AEFeature.java b/core/features/AEFeature.java index 69629b28f..5029b8be1 100644 --- a/core/features/AEFeature.java +++ b/core/features/AEFeature.java @@ -56,7 +56,7 @@ public enum AEFeature enableDisassemblyCrafting("Crafting"), MolecularAssembler("CraftingFeatures"), MeteoriteCompass("Tools"), Patterns("CraftingFeatures"), - ChunkLoggerTrace("Commands", false); + ChunkLoggerTrace("Commands", false), LogSecurityAudits("Misc", false); String Category; boolean visible = true; diff --git a/me/GridConnection.java b/me/GridConnection.java index b3f0474c2..8e6a11be7 100644 --- a/me/GridConnection.java +++ b/me/GridConnection.java @@ -11,6 +11,9 @@ import appeng.api.networking.IGridNode; import appeng.api.networking.events.MENetworkChannelsChanged; import appeng.api.networking.pathing.IPathingGrid; import appeng.api.util.IReadOnlyCollection; +import appeng.core.AEConfig; +import appeng.core.AELog; +import appeng.core.features.AEFeature; import appeng.me.pathfinding.IPathItem; import appeng.util.Platform; import appeng.util.ReadOnlyCollection; @@ -34,7 +37,15 @@ public class GridConnection implements IGridConnection, IPathItem GridNode b = (GridNode) bNode; if ( Platform.securityCheck( a, b ) ) + { + if ( AEConfig.instance.isFeatureEnabled( AEFeature.LogSecurityAudits ) ) + { + AELog.info( "Audit Failed 1: " + a.getGridBlock().getLocation() ); + AELog.info( "Audit Failed 2: " + b.getGridBlock().getLocation() ); + } + throw new FailedConnection(); + } if ( a == null || b == null ) throw new GridException( "Connection Forged Between null enties." ); diff --git a/util/Platform.java b/util/Platform.java index d7837ac26..42a422d15 100644 --- a/util/Platform.java +++ b/util/Platform.java @@ -1504,6 +1504,11 @@ public class Platform boolean a_isSecure = isPowered( a.getGrid() ) && a.lastSecurityKey != -1; boolean b_isSecure = isPowered( b.getGrid() ) && b.lastSecurityKey != -1; + if ( AEConfig.instance.isFeatureEnabled( AEFeature.LogSecurityAudits ) ) + { + AELog.info( "Audit: " + a_isSecure + " : " + b_isSecure + " @ " + a.lastSecurityKey + " vs " + b.lastSecurityKey ); + } + // can't do that son... if ( a_isSecure && b_isSecure ) return true;