提交 eecac4bb 编写于 作者: D Daniel Leaver 提交者: GitHub

3.5 ssrf cp () ()

* Adds blocklist of ip addresses for LOAD CSV ()

(cherry picked from commit ef528de323228e8fb1d74d931d5b3f4a4907e21f)

Follows redirect url to resolve blocked LOAD CSV urls ()

(cherry picked from commit fd2a6ce4a1902d40170d57c86cd5315691e166f4)

* Revapi ignore cypher_ip_blocklist
Co-authored-by: NNacho Cordón <ncordon@users.noreply.github.com>
上级 e0c6c55d
......@@ -9,6 +9,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -31,6 +31,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -6,6 +6,7 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
Apache Software License, Version 2.0
Apache Commons Lang
Apache Commons Text
IPAddress
Lucene Core
Netty/All-in-One
------------------------------------------------------------------------------
......
......@@ -28,6 +28,7 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Lang
Apache Commons Text
IPAddress
Lucene Core
Netty/All-in-One
......
......@@ -10,6 +10,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -10,6 +10,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -10,6 +10,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -10,6 +10,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -10,6 +10,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -10,6 +10,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -10,6 +10,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -10,6 +10,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -10,6 +10,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -10,6 +10,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -5,6 +5,7 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
------------------------------------------------------------------------------
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
------------------------------------------------------------------------------
Apache License
......
......@@ -27,6 +27,7 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Eclipse Distribution License - v 1.0
Eclipse Collections API
......
......@@ -86,5 +86,10 @@ the relevant Commercial Agreement.
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>com.github.seancfoley</groupId>
<artifactId>ipaddress</artifactId>
<version>5.3.3</version>
</dependency>
</dependencies>
</project>
......@@ -7,6 +7,7 @@ Apache Software License, Version 2.0
Apache Commons Compress
Apache Commons Lang
Apache Commons Text
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -29,6 +29,7 @@ Apache Software License, Version 2.0
Apache Commons Compress
Apache Commons Lang
Apache Commons Text
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -9,6 +9,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -31,6 +31,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -9,6 +9,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -31,6 +31,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -9,6 +9,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -31,6 +31,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -5,6 +5,7 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
------------------------------------------------------------------------------
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene Core
Netty/All-in-One
parboiled-core
......
......@@ -27,6 +27,7 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene Core
Netty/All-in-One
parboiled-core
......
......@@ -5,6 +5,7 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
------------------------------------------------------------------------------
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene Core
Netty/All-in-One
parboiled-core
......
......@@ -27,6 +27,7 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene Core
Netty/All-in-One
parboiled-core
......
......@@ -5,6 +5,7 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
------------------------------------------------------------------------------
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene Core
Netty/All-in-One
parboiled-core
......
......@@ -27,6 +27,7 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene Core
Netty/All-in-One
parboiled-core
......
......@@ -9,6 +9,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -31,6 +31,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -6,6 +6,7 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
Apache Software License, Version 2.0
Apache Commons Compress
Apache Commons Text
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -28,6 +28,7 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Compress
Apache Commons Text
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -5,6 +5,7 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
------------------------------------------------------------------------------
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -27,6 +27,7 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -5,6 +5,7 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
------------------------------------------------------------------------------
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene Core
Netty/All-in-One
------------------------------------------------------------------------------
......
......@@ -27,6 +27,7 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene Core
Netty/All-in-One
......
......@@ -5,6 +5,7 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
------------------------------------------------------------------------------
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -27,6 +27,7 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -5,6 +5,7 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
------------------------------------------------------------------------------
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene Core
Netty/All-in-One
------------------------------------------------------------------------------
......
......@@ -27,6 +27,7 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene Core
Netty/All-in-One
......
......@@ -19,6 +19,8 @@
*/
package org.neo4j.graphdb.factory;
import inet.ipaddr.IPAddressString;
import java.io.File;
import java.time.Duration;
import java.time.ZoneId;
......@@ -55,6 +57,7 @@ import static org.neo4j.kernel.configuration.Settings.BOOLEAN;
import static org.neo4j.kernel.configuration.Settings.BYTES;
import static org.neo4j.kernel.configuration.Settings.DEFAULT;
import static org.neo4j.kernel.configuration.Settings.DOUBLE;
import static org.neo4j.kernel.configuration.Settings.CIDR_IP;
import static org.neo4j.kernel.configuration.Settings.DURATION;
import static org.neo4j.kernel.configuration.Settings.FALSE;
import static org.neo4j.kernel.configuration.Settings.INTEGER;
......@@ -111,6 +114,15 @@ public class GraphDatabaseSettings implements LoadableConfig
public static final Setting<File> neo4j_home =
setting( "unsupported.dbms.directories.neo4j_home", PATH, NO_DEFAULT );
/**
* LOAD CSV and apoc.load.json input URI restrictions
*/
@Internal
@Description( "A list of CIDR-notation IPv4 or IPv6 addresses to block when accessing URLs." +
"This list is checked when LOAD CSV or apoc.load.json is called." )
public static final Setting<List<IPAddressString>> cypher_ip_blocklist = setting(
"unsupported.dbms.cypher_ip_blocklist", list( ",", CIDR_IP ), "" );
/**
* @deprecated This setting is deprecated and will be removed in 4.0.
*/
......
......@@ -19,6 +19,8 @@
*/
package org.neo4j.kernel.configuration;
import inet.ipaddr.AddressStringException;
import inet.ipaddr.IPAddressString;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -193,7 +195,7 @@ public class Settings
* @param <T> the concrete type of the setting.
*/
@Nonnull
public static <T> Setting<T> setting( @Nonnull final String name, @Nonnull final Function<String,T> parser,
public static <T> Setting<T> setting( @Nonnull final String name, @Nonnull final Function<String, T> parser,
@Nullable final String defaultValue )
{
return new SettingBuilder<>( name, parser, defaultValue ).build();
......@@ -521,6 +523,30 @@ public class Settings
}
};
public static final Function<String, IPAddressString> CIDR_IP = new Function<String, IPAddressString>()
{
@Override
public IPAddressString apply( String value )
{
IPAddressString ipAddress = new IPAddressString( value.trim() );
try
{
ipAddress.validate();
}
catch ( AddressStringException e )
{
throw new IllegalArgumentException( format( "'%s' is not a valid CIDR ip", value ), e );
}
return ipAddress;
}
@Override
public String toString()
{
return "an ip with subnet in CDIR format. e.g. 127.168.0.1/8";
}
};
public static final Function<String,Duration> DURATION = new Function<String, Duration>()
{
@Override
......
......@@ -44,6 +44,13 @@ public class URLAccessRules
return FILE_ACCESS;
}
private static final URLAccessRule WEB_ACCESS = new WebURLAccessRule();
public static URLAccessRule webAccess()
{
return WEB_ACCESS;
}
public static URLAccessRule combined( final Map<String,URLAccessRule> urlAccessRules )
{
return ( config, url ) ->
......
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.kernel.impl.security;
import inet.ipaddr.IPAddressString;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
import java.util.List;
import org.neo4j.graphdb.config.Configuration;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.graphdb.security.URLAccessRule;
import org.neo4j.graphdb.security.URLAccessValidationError;
public class WebURLAccessRule implements URLAccessRule
{
public static void checkNotBlocked( URL url, List<IPAddressString> blockedIpRanges ) throws Exception
{
InetAddress inetAddress = InetAddress.getByName( url.getHost() );
for ( IPAddressString blockedIpRange : blockedIpRanges )
{
if ( blockedIpRange.contains( new IPAddressString( inetAddress.getHostAddress() ) ) )
{
throw new URLAccessValidationError( "access to " + inetAddress + " is blocked via the configuration property "
+ GraphDatabaseSettings.cypher_ip_blocklist.name() );
}
}
}
private static URL checkUrlIncludingHoops( URL url, List<IPAddressString> blockedIpRanges ) throws Exception
{
URL result = url;
boolean isRedirect;
do
{
// We need to validate each intermediate url if there are redirects.
// Otherwise, we could have situations like an internal ip, e.g. 10.0.0.1
// is banned in the config, but it redirects to another different internal ip
// and we would still have a security hole
checkNotBlocked( result, blockedIpRanges );
HttpURLConnection con = (HttpURLConnection) result.openConnection();
con.setInstanceFollowRedirects( false );
con.connect();
con.getInputStream();
isRedirect = con.getResponseCode() >= 300 && con.getResponseCode() < 400;
if ( isRedirect )
{
String location = con.getHeaderField( "Location" );
if ( location == null )
{
throw new IOException( "URL responded with a redirect but the location header was null" );
}
// If the path is relative, we need to adjust it with respect to the original url
if ( location.startsWith( "/" ) )
{
location = result.getProtocol() + "://" + result.getAuthority() + location;
}
result = new URL( location );
}
con.disconnect();
}
while ( isRedirect );
return result;
}
@Override
public URL validate( Configuration config, URL url ) throws URLAccessValidationError
{
List<IPAddressString> blockedIpRanges = config.get( GraphDatabaseSettings.cypher_ip_blocklist );
String host = url.getHost();
if ( !blockedIpRanges.isEmpty() && host != null && !host.isEmpty() )
{
try
{
checkUrlIncludingHoops( url, blockedIpRanges );
}
catch ( Exception e )
{
throw new URLAccessValidationError( "Unable to verify access to " + host + ". Cause: " + e.getMessage() );
}
}
return url;
}
}
......@@ -19,6 +19,7 @@
*/
package org.neo4j.kernel.configuration;
import inet.ipaddr.IPAddressString;
import org.junit.jupiter.api.Test;
import java.io.File;
......@@ -42,9 +43,11 @@ import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.neo4j.helpers.collection.MapUtil.stringMap;
import static org.neo4j.kernel.configuration.Settings.CIDR_IP;
import static org.neo4j.kernel.configuration.Settings.DURATION;
import static org.neo4j.kernel.configuration.Settings.INTEGER;
import static org.neo4j.kernel.configuration.Settings.LONG;
......@@ -261,6 +264,25 @@ class SettingsTest
assertThat( exception.getMessage(), containsString( "Unrecognized unit 'gigaseconds'" ) );
}
@Test
void testCidrIp()
{
Setting<IPAddressString> setting = buildSetting( "foo.bar", CIDR_IP ).build();
assertEquals( new IPAddressString( "1.1.1.0/8" ), setting.apply( map( stringMap( "foo.bar", "1.1.1.0/8" ) ) ) );
assertThrows( InvalidSettingException.class, () -> setting.apply( map( stringMap( "foo.bar", "garbage" ) ) ) );
}
@Test
void testCidrIpList()
{
Setting<List<IPAddressString>> setting = setting( "foo.bar", list( ",", CIDR_IP ), "" );
assertEquals( Arrays.asList( new IPAddressString( "1.1.1.0/8" ) ), setting.apply( map( stringMap( "foo.bar", "1.1.1.0/8" ) ) ) );
assertEquals( Arrays.asList( new IPAddressString( "1.1.1.0/8" ), new IPAddressString( "124.0.255.255/1" ) ),
setting.apply( map( stringMap( "foo.bar", "1.1.1.0/8,124.0.255.255/1" ) ) ) );
assertEquals( Arrays.asList() , setting.apply( map( stringMap( "foo.bar", "" ) ) ) );
assertThrows( InvalidSettingException.class, () -> setting.apply( map( stringMap( "foo.bar", "garbage" ) ) ) );
}
@Test
void testDefault()
{
......
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.kernel.impl.security;
import org.junit.jupiter.api.Test;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.graphdb.security.URLAccessValidationError;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.neo4j.helpers.collection.MapUtil.stringMap;
class WebURLAccessRuleTest
{
@Test
void shouldThrowWhenUrlIsWithinBlockedRange() throws MalformedURLException
{
final List<String> urlAddresses = Arrays.asList( "http://localhost/test.csv", "https://localhost/test.csv", "ftp://localhost/test.csv", "http://[::1]/test.csv" );
for ( String urlAddress : urlAddresses )
{
final URL url = new URL( urlAddress );
//set the config
final Config config = Config.defaults( stringMap( GraphDatabaseSettings.cypher_ip_blocklist.name(), "127.0.0.0/8,0:0:0:0:0:0:0:1/8"));
//execute the query
final URLAccessValidationError error = assertThrows( URLAccessValidationError.class, () ->
URLAccessRules.webAccess().validate( config, url ) );
//assert that the validation fails
assertThat( error.getMessage(), containsString( "blocked via the configuration property unsupported.dbms.cypher_ip_blocklist" ));
}
}
@Test
void validationShouldPassWhenUrlIsNotWithinBlockedRange() throws MalformedURLException, URLAccessValidationError
{
final List<String> urlAddresses = Arrays.asList( "http://localhost/test.csv", "https://localhost/test.csv", "ftp://localhost/test.csv", "http://[::1]/test.csv" );
for ( String urlAddress : urlAddresses )
{
final URL url = new URL( urlAddress );
//set the config
final Config config = Config.defaults();
//execute the query
final URL result = URLAccessRules.webAccess().validate( config, url );
//assert that the validation passes
assert result == url;
}
}
@Test
void shouldWorkWithNonRangeIps() throws MalformedURLException
{
final URL url = new URL( "http://localhost/test.csv" );
//set the config
final Config config = Config.defaults( stringMap( GraphDatabaseSettings.cypher_ip_blocklist.name(), "127.0.0.1"));
//execute the query
final URLAccessValidationError error = assertThrows( URLAccessValidationError.class, () ->
URLAccessRules.webAccess().validate( config, url ) );
//assert that the validation fails
assertThat( error.getMessage(), containsString( "blocked via the configuration property unsupported.dbms.cypher_ip_blocklist" ));
}
@Test
void shouldFailForInvalidIps() throws Exception
{
// The .invalid domain is always invalid, according to https://datatracker.ietf.org/doc/html/rfc2606#section-2
final URL url = new URL( "http://always.invalid/test.csv" );
//set the config
final Config config = Config.defaults( stringMap( GraphDatabaseSettings.cypher_ip_blocklist.name(), "127.0.0.1"));
//execute the query
final URLAccessValidationError error = assertThrows( URLAccessValidationError.class, () ->
URLAccessRules.webAccess().validate( config, url ) );
//assert that the validation fails
assertThat( error.getMessage(), containsString( "Unable to verify access to always.invalid" ));
}
}
......@@ -5,6 +5,7 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
------------------------------------------------------------------------------
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -27,6 +27,7 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene codecs
Lucene Common Analyzers
Lucene Core
......
......@@ -10,6 +10,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -18,6 +18,7 @@ Apache Software License, Version 2.0
ConcurrentLinkedHashMap
error-prone annotations
fastinfoset
IPAddress
Jackson module: Old JAXB Annotations (javax.xml.bind)
Jackson-annotations
Jackson-core
......
......@@ -40,6 +40,7 @@ Apache Software License, Version 2.0
ConcurrentLinkedHashMap
error-prone annotations
fastinfoset
IPAddress
Jackson module: Old JAXB Annotations (javax.xml.bind)
Jackson-annotations
Jackson-core
......
......@@ -10,6 +10,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
Caffeine cache
ConcurrentLinkedHashMap
error-prone annotations
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -64,9 +64,9 @@ public class GraphDatabaseDependencies implements GraphDatabaseFacadeFactory.Dep
getKernelExtensions(Service.load( KernelExtensionFactory.class ).iterator()));
ImmutableMap<String,URLAccessRule> urlAccessRules = ImmutableMapFactoryImpl.INSTANCE.of(
"http", URLAccessRules.alwaysPermitted(),
"https", URLAccessRules.alwaysPermitted(),
"ftp", URLAccessRules.alwaysPermitted(),
"http", URLAccessRules.webAccess(),
"https", URLAccessRules.webAccess(),
"ftp", URLAccessRules.webAccess(),
"file", URLAccessRules.fileAccess()
);
......
......@@ -7,6 +7,7 @@ Apache Software License, Version 2.0
Apache Commons Compress
Apache Commons Lang
Apache Commons Text
IPAddress
Jackson-annotations
Jackson-core
jackson-databind
......
......@@ -20,6 +20,7 @@ Apache Software License, Version 2.0
Apache Commons Compress
Apache Commons Lang
Apache Commons Text
IPAddress
Jackson-annotations
Jackson-core
jackson-databind
......
......@@ -7,6 +7,7 @@ Apache Software License, Version 2.0
Apache Commons Compress
Apache Commons Lang
Apache Commons Text
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -29,6 +29,7 @@ Apache Software License, Version 2.0
Apache Commons Compress
Apache Commons Lang
Apache Commons Text
IPAddress
jPowerShell
jProcesses
Lucene codecs
......
......@@ -8,6 +8,7 @@ Apache Software License, Version 2.0
Apache Commons Lang
Commons Lang
Commons Logging
IPAddress
Lucene Core
Netty/All-in-One
------------------------------------------------------------------------------
......
......@@ -30,6 +30,7 @@ Apache Software License, Version 2.0
Apache Commons Lang
Commons Lang
Commons Logging
IPAddress
Lucene Core
Netty/All-in-One
......
......@@ -15,6 +15,7 @@ Apache Software License, Version 2.0
ConcurrentLinkedHashMap
error-prone annotations
fastinfoset
IPAddress
Jackson module: Old JAXB Annotations (javax.xml.bind)
Jackson-annotations
Jackson-core
......
......@@ -37,6 +37,7 @@ Apache Software License, Version 2.0
ConcurrentLinkedHashMap
error-prone annotations
fastinfoset
IPAddress
Jackson module: Old JAXB Annotations (javax.xml.bind)
Jackson-annotations
Jackson-core
......
......@@ -15,6 +15,7 @@ Apache Software License, Version 2.0
ConcurrentLinkedHashMap
error-prone annotations
fastinfoset
IPAddress
Jackson module: Old JAXB Annotations (javax.xml.bind)
Jackson-annotations
Jackson-core
......
......@@ -37,6 +37,7 @@ Apache Software License, Version 2.0
ConcurrentLinkedHashMap
error-prone annotations
fastinfoset
IPAddress
Jackson module: Old JAXB Annotations (javax.xml.bind)
Jackson-annotations
Jackson-core
......
......@@ -5,6 +5,7 @@ libraries. For an overview of the licenses see the NOTICE.txt file.
------------------------------------------------------------------------------
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene Core
Netty/All-in-One
------------------------------------------------------------------------------
......
......@@ -27,6 +27,7 @@ Third-party licenses
Apache Software License, Version 2.0
Apache Commons Lang
IPAddress
Lucene Core
Netty/All-in-One
......
......@@ -32,6 +32,7 @@ Apache Software License, Version 2.0
firebase
forever-agent
grpc
IPAddress
long
Lucene codecs
Lucene Common Analyzers
......
......@@ -48,6 +48,7 @@ Apache Software License, Version 2.0
firebase
forever-agent
grpc
IPAddress
long
Lucene codecs
Lucene Common Analyzers
......
......@@ -42,6 +42,7 @@ Apache Software License, Version 2.0
firebase
forever-agent
grpc
IPAddress
Jackson module: Old JAXB Annotations (javax.xml.bind)
Jackson-annotations
Jackson-core
......
......@@ -64,6 +64,7 @@ Apache Software License, Version 2.0
firebase
forever-agent
grpc
IPAddress
Jackson module: Old JAXB Annotations (javax.xml.bind)
Jackson-annotations
Jackson-core
......
......@@ -271,6 +271,7 @@
<item>org\.neo4j\.server\.rest\.repr\.RepresentationType</item>
<item>org\.neo4j\.server\.rest\.repr\.ValueRepresentation</item>
<item>org\.neo4j\.server\.helpers\.PropertyTypeDispatcher</item>
<item>org\.neo4j\.helpers\.PortBindException</item>
</exclude>
</classes>
<packages>
......@@ -347,6 +348,11 @@
<new>field org.neo4j.graphdb.factory.GraphDatabaseSettings.log_inconsistent_data_deletion</new>
<justification>Adding an internal setting for logging of inconsistent data on delete.</justification>
</item>
<item>
<code>java.field.addedStaticField</code>
<new>field org.neo4j.graphdb.factory.GraphDatabaseSettings.cypher_ip_blocklist</new>
<justification>Adding an internal setting for blocking IP ranges when making http requests.</justification>
</item>
<item>
<code>java.annotation.attributeValueChanged</code>
<new>field org.neo4j.graphdb.factory.GraphDatabaseSettings.query_statistics_divergence_threshold</new>
......@@ -357,6 +363,11 @@
<new>field org.neo4j.graphdb.factory.GraphDatabaseSettings.log_queries_detailed_time_logging_enabled</new>
<justification>Correcting setting description for documentation</justification>
</item>
<item>
<code>java.method.finalMethodAddedToNonFinalClass</code>
<new>method void java.lang.Throwable::addSuppressed(java.lang.Throwable) @ org.neo4j.helpers.PortBindException</new>
<justification>Correcting setting description for documentation</justification>
</item>
</revapi.ignore>
<revapi.semver.ignore>
<enabled>true</enabled>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册