diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-08-21 01:15:46 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-08-21 01:15:46 +1200 |
commit | 9fb1f19aab9e4535c1c208fdd3dc0e986940b160 (patch) | |
tree | c10454ce4180a2d5999ea587c90bdd9ff8d66229 /src | |
parent | 901bcf5da82eb7d1370856ceb732397e8ef4c670 (diff) | |
download | traccar-server-9fb1f19aab9e4535c1c208fdd3dc0e986940b160.tar.gz traccar-server-9fb1f19aab9e4535c1c208fdd3dc0e986940b160.tar.bz2 traccar-server-9fb1f19aab9e4535c1c208fdd3dc0e986940b160.zip |
Prevent PatternUtil in production
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/helper/PatternUtil.java | 7 | ||||
-rw-r--r-- | src/org/traccar/protocol/EskyProtocolDecoder.java | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/org/traccar/helper/PatternUtil.java b/src/org/traccar/helper/PatternUtil.java index 12536eaef..1bbb166a6 100644 --- a/src/org/traccar/helper/PatternUtil.java +++ b/src/org/traccar/helper/PatternUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package org.traccar.helper; +import java.lang.management.ManagementFactory; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -49,6 +50,10 @@ public final class PatternUtil { public static MatchResult checkPattern(String pattern, String input) { + if (!ManagementFactory.getRuntimeMXBean().getInputArguments().toString().contains("-agentlib:jdwp")) { + throw new RuntimeException("PatternUtil usage detected"); + } + MatchResult result = new MatchResult(); for (int i = 0; i < pattern.length(); i++) { diff --git a/src/org/traccar/protocol/EskyProtocolDecoder.java b/src/org/traccar/protocol/EskyProtocolDecoder.java index c12753881..0d3dcafb2 100644 --- a/src/org/traccar/protocol/EskyProtocolDecoder.java +++ b/src/org/traccar/protocol/EskyProtocolDecoder.java @@ -55,9 +55,6 @@ public class EskyProtocolDecoder extends BaseProtocolDecoder { protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { - org.traccar.helper.PatternUtil.MatchResult matchResult = - org.traccar.helper.PatternUtil.checkPattern(PATTERN.pattern(), (String) msg); - Parser parser = new Parser(PATTERN, (String) msg); if (!parser.matches()) { return null; |