Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d7fe734b
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d7fe734b
编写于
10月 23, 2019
作者:
A
alvdavi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8231422: Better serial filter handling
Reviewed-by: andrew
上级
7459aba3
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
97 addition
and
20 deletion
+97
-20
src/share/classes/java/lang/System.java
src/share/classes/java/lang/System.java
+3
-0
src/share/classes/jdk/internal/util/StaticProperty.java
src/share/classes/jdk/internal/util/StaticProperty.java
+58
-0
src/share/classes/sun/misc/ObjectInputFilter.java
src/share/classes/sun/misc/ObjectInputFilter.java
+3
-1
src/share/lib/security/java.security-aix
src/share/lib/security/java.security-aix
+2
-2
src/share/lib/security/java.security-linux
src/share/lib/security/java.security-linux
+2
-2
src/share/lib/security/java.security-macosx
src/share/lib/security/java.security-macosx
+2
-2
src/share/lib/security/java.security-solaris
src/share/lib/security/java.security-solaris
+2
-2
src/share/lib/security/java.security-windows
src/share/lib/security/java.security-windows
+2
-2
test/java/io/Serializable/serialFilter/GlobalFilterTest.java
test/java/io/Serializable/serialFilter/GlobalFilterTest.java
+22
-8
test/java/io/Serializable/serialFilter/security.policy
test/java/io/Serializable/serialFilter/security.policy
+1
-1
未找到文件。
src/share/classes/java/lang/System.java
浏览文件 @
d7fe734b
...
@@ -43,6 +43,8 @@ import sun.reflect.Reflection;
...
@@ -43,6 +43,8 @@ import sun.reflect.Reflection;
import
sun.security.util.SecurityConstants
;
import
sun.security.util.SecurityConstants
;
import
sun.reflect.annotation.AnnotationType
;
import
sun.reflect.annotation.AnnotationType
;
import
jdk.internal.util.StaticProperty
;
/**
/**
* The <code>System</code> class contains several useful class fields
* The <code>System</code> class contains several useful class fields
* and methods. It cannot be instantiated.
* and methods. It cannot be instantiated.
...
@@ -1183,6 +1185,7 @@ public final class System {
...
@@ -1183,6 +1185,7 @@ public final class System {
lineSeparator
=
props
.
getProperty
(
"line.separator"
);
lineSeparator
=
props
.
getProperty
(
"line.separator"
);
StaticProperty
.
jdkSerialFilter
();
// Load StaticProperty to cache the property values
sun
.
misc
.
Version
.
init
();
sun
.
misc
.
Version
.
init
();
FileInputStream
fdIn
=
new
FileInputStream
(
FileDescriptor
.
in
);
FileInputStream
fdIn
=
new
FileInputStream
(
FileDescriptor
.
in
);
...
...
src/share/classes/jdk/internal/util/StaticProperty.java
0 → 100644
浏览文件 @
d7fe734b
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
jdk.internal.util
;
/**
* System Property access for internal use only.
* Read-only access to System property values initialized during Phase 1
* are cached. Setting, clearing, or modifying the value using
* {@link System#setProperty) or {@link System#getProperties()} is ignored.
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
* in these access methods. The caller of these methods should take care to ensure
* that the returned property is not made accessible to untrusted code.</strong>
*/
public
final
class
StaticProperty
{
// The class static initialization is triggered to initialize these final
// fields during init Phase 1 and before a security manager is set.
private
static
final
String
JDK_SERIAL_FILTER
=
System
.
getProperty
(
"jdk.serialFilter"
);
private
StaticProperty
()
{}
/**
*
* Return the {@code jdk.serialFilter} system property.
*
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
* in this method. The caller of this method should take care to ensure
* that the returned property is not made accessible to untrusted code.</strong>
*
* @return the {@code user.name} system property
*/
public
static
String
jdkSerialFilter
()
{
return
JDK_SERIAL_FILTER
;
}
}
src/share/classes/sun/misc/ObjectInputFilter.java
浏览文件 @
d7fe734b
...
@@ -37,6 +37,8 @@ import java.util.Optional;
...
@@ -37,6 +37,8 @@ import java.util.Optional;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
sun.util.logging.PlatformLogger
;
import
sun.util.logging.PlatformLogger
;
import
jdk.internal.util.StaticProperty
;
/**
/**
* Filter classes, array lengths, and graph metrics during deserialization.
* Filter classes, array lengths, and graph metrics during deserialization.
* If set on an {@link ObjectInputStream}, the {@link #checkInput checkInput(FilterInfo)}
* If set on an {@link ObjectInputStream}, the {@link #checkInput checkInput(FilterInfo)}
...
@@ -247,7 +249,7 @@ public interface ObjectInputFilter {
...
@@ -247,7 +249,7 @@ public interface ObjectInputFilter {
static
{
static
{
configuredFilter
=
AccessController
configuredFilter
=
AccessController
.
doPrivileged
((
PrivilegedAction
<
ObjectInputFilter
>)
()
->
{
.
doPrivileged
((
PrivilegedAction
<
ObjectInputFilter
>)
()
->
{
String
props
=
S
ystem
.
getProperty
(
SERIAL_FILTER_PROPNAME
);
String
props
=
S
taticProperty
.
jdkSerialFilter
(
);
if
(
props
==
null
)
{
if
(
props
==
null
)
{
props
=
Security
.
getProperty
(
SERIAL_FILTER_PROPNAME
);
props
=
Security
.
getProperty
(
SERIAL_FILTER_PROPNAME
);
}
}
...
...
src/share/lib/security/java.security-aix
浏览文件 @
d7fe734b
...
@@ -886,8 +886,8 @@ jdk.xml.dsig.secureValidationPolicy=\
...
@@ -886,8 +886,8 @@ jdk.xml.dsig.secureValidationPolicy=\
# Patterns are separated by ";" (semicolon).
# Patterns are separated by ";" (semicolon).
# Whitespace is significant and is considered part of the pattern.
# Whitespace is significant and is considered part of the pattern.
#
#
# If the system property jdk.serialFilter is also specified
, it supersedes
# If the system property jdk.serialFilter is also specified
on the command
# the security property value defined here.
#
line, it supersedes
the security property value defined here.
#
#
# If a pattern includes a "=", it sets a limit.
# If a pattern includes a "=", it sets a limit.
# If a limit appears more than once the last value is used.
# If a limit appears more than once the last value is used.
...
...
src/share/lib/security/java.security-linux
浏览文件 @
d7fe734b
...
@@ -887,8 +887,8 @@ jdk.xml.dsig.secureValidationPolicy=\
...
@@ -887,8 +887,8 @@ jdk.xml.dsig.secureValidationPolicy=\
# Patterns are separated by ";" (semicolon).
# Patterns are separated by ";" (semicolon).
# Whitespace is significant and is considered part of the pattern.
# Whitespace is significant and is considered part of the pattern.
#
#
# If the system property jdk.serialFilter is also specified
, it supersedes
# If the system property jdk.serialFilter is also specified
on the command
# the security property value defined here.
#
line, it supersedes
the security property value defined here.
#
#
# If a pattern includes a "=", it sets a limit.
# If a pattern includes a "=", it sets a limit.
# If a limit appears more than once the last value is used.
# If a limit appears more than once the last value is used.
...
...
src/share/lib/security/java.security-macosx
浏览文件 @
d7fe734b
...
@@ -890,8 +890,8 @@ jdk.xml.dsig.secureValidationPolicy=\
...
@@ -890,8 +890,8 @@ jdk.xml.dsig.secureValidationPolicy=\
# Patterns are separated by ";" (semicolon).
# Patterns are separated by ";" (semicolon).
# Whitespace is significant and is considered part of the pattern.
# Whitespace is significant and is considered part of the pattern.
#
#
# If the system property jdk.serialFilter is also specified
, it supersedes
# If the system property jdk.serialFilter is also specified
on the command
# the security property value defined here.
#
line, it supersedes
the security property value defined here.
#
#
# If a pattern includes a "=", it sets a limit.
# If a pattern includes a "=", it sets a limit.
# If a limit appears more than once the last value is used.
# If a limit appears more than once the last value is used.
...
...
src/share/lib/security/java.security-solaris
浏览文件 @
d7fe734b
...
@@ -889,8 +889,8 @@ jdk.xml.dsig.secureValidationPolicy=\
...
@@ -889,8 +889,8 @@ jdk.xml.dsig.secureValidationPolicy=\
# Patterns are separated by ";" (semicolon).
# Patterns are separated by ";" (semicolon).
# Whitespace is significant and is considered part of the pattern.
# Whitespace is significant and is considered part of the pattern.
#
#
# If the system property jdk.serialFilter is also specified
, it supersedes
# If the system property jdk.serialFilter is also specified
on the command
# the security property value defined here.
#
line, it supersedes
the security property value defined here.
#
#
# If a pattern includes a "=", it sets a limit.
# If a pattern includes a "=", it sets a limit.
# If a limit appears more than once the last value is used.
# If a limit appears more than once the last value is used.
...
...
src/share/lib/security/java.security-windows
浏览文件 @
d7fe734b
...
@@ -890,8 +890,8 @@ jdk.xml.dsig.secureValidationPolicy=\
...
@@ -890,8 +890,8 @@ jdk.xml.dsig.secureValidationPolicy=\
# Patterns are separated by ";" (semicolon).
# Patterns are separated by ";" (semicolon).
# Whitespace is significant and is considered part of the pattern.
# Whitespace is significant and is considered part of the pattern.
#
#
# If the system property jdk.serialFilter is also specified
, it supersedes
# If the system property jdk.serialFilter is also specified
on the command
# the security property value defined here.
#
line, it supersedes
the security property value defined here.
#
#
# If a pattern includes a "=", it sets a limit.
# If a pattern includes a "=", it sets a limit.
# If a limit appears more than once the last value is used.
# If a limit appears more than once the last value is used.
...
...
test/java/io/Serializable/serialFilter/GlobalFilterTest.java
浏览文件 @
d7fe734b
/*
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016,
2019,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -42,9 +42,11 @@ import org.testng.annotations.DataProvider;
...
@@ -42,9 +42,11 @@ import org.testng.annotations.DataProvider;
import
sun.misc.ObjectInputFilter
;
import
sun.misc.ObjectInputFilter
;
/* @test
/* @test
* @bug 8231422
* @build GlobalFilterTest SerialFilterTest
* @build GlobalFilterTest SerialFilterTest
* @run testng/othervm GlobalFilterTest
* @run testng/othervm GlobalFilterTest
* @run testng/othervm -Djdk.serialFilter=java.** GlobalFilterTest
* @run testng/othervm -Djdk.serialFilter=java.**
* -Dexpected-jdk.serialFilter=java.** GlobalFilterTest
* @run testng/othervm/policy=security.policy GlobalFilterTest
* @run testng/othervm/policy=security.policy GlobalFilterTest
* @run testng/othervm/policy=security.policy
* @run testng/othervm/policy=security.policy
* -Djava.security.properties=${test.src}/java.security-extra1
* -Djava.security.properties=${test.src}/java.security-extra1
...
@@ -54,6 +56,10 @@ import sun.misc.ObjectInputFilter;
...
@@ -54,6 +56,10 @@ import sun.misc.ObjectInputFilter;
*/
*/
@Test
@Test
public
class
GlobalFilterTest
{
public
class
GlobalFilterTest
{
private
static
final
String
serialPropName
=
"jdk.serialFilter"
;
private
static
final
String
badSerialFilter
=
"java.lang.StringBuffer;!*"
;
private
static
final
String
origSerialFilterProperty
=
System
.
setProperty
(
serialPropName
,
badSerialFilter
);
/**
/**
* DataProvider of patterns and objects derived from the configured process-wide filter.
* DataProvider of patterns and objects derived from the configured process-wide filter.
...
@@ -62,8 +68,8 @@ public class GlobalFilterTest {
...
@@ -62,8 +68,8 @@ public class GlobalFilterTest {
@DataProvider
(
name
=
"globalPatternElements"
)
@DataProvider
(
name
=
"globalPatternElements"
)
Object
[][]
globalPatternElements
()
{
Object
[][]
globalPatternElements
()
{
String
globalFilter
=
String
globalFilter
=
System
.
getProperty
(
"
jdk.serialFilter"
,
System
.
getProperty
(
"
expected-"
+
serialPropName
,
Security
.
getProperty
(
"jdk.serialFilter"
));
Security
.
getProperty
(
serialPropName
));
if
(
globalFilter
==
null
)
{
if
(
globalFilter
==
null
)
{
return
new
Object
[
0
][];
return
new
Object
[
0
][];
}
}
...
@@ -100,12 +106,20 @@ public class GlobalFilterTest {
...
@@ -100,12 +106,20 @@ public class GlobalFilterTest {
*/
*/
@Test
()
@Test
()
static
void
globalFilter
()
{
static
void
globalFilter
()
{
String
pattern
=
System
.
getProperty
(
"jdk.serialFilter"
,
Security
.
getProperty
(
"jdk.serialFilter"
));
ObjectInputFilter
filter
=
ObjectInputFilter
.
Config
.
getSerialFilter
();
ObjectInputFilter
filter
=
ObjectInputFilter
.
Config
.
getSerialFilter
();
// Check that the System.setProperty(jdk.serialFilter) DOES NOT affect the filter.
String
asSetSystemProp
=
System
.
getProperty
(
serialPropName
,
Security
.
getProperty
(
serialPropName
));
Assert
.
assertNotEquals
(
Objects
.
toString
(
filter
,
null
),
asSetSystemProp
,
"System.setProperty(\"jdk.serialfilter\", ...) should not change filter: "
+
asSetSystemProp
);
String
pattern
=
System
.
getProperty
(
"expected-"
+
serialPropName
,
Security
.
getProperty
(
serialPropName
));
System
.
out
.
printf
(
"global pattern: %s, filter: %s%n"
,
pattern
,
filter
);
System
.
out
.
printf
(
"global pattern: %s, filter: %s%n"
,
pattern
,
filter
);
Assert
.
assertEquals
(
pattern
,
Objects
.
toString
(
filter
,
null
)
,
Assert
.
assertEquals
(
Objects
.
toString
(
filter
,
null
),
pattern
,
"process-wide filter pattern does not match"
);
"process-wide filter pattern does not match"
);
}
}
...
...
test/java/io/Serializable/serialFilter/security.policy
浏览文件 @
d7fe734b
...
@@ -3,7 +3,7 @@ grant {
...
@@ -3,7 +3,7 @@ grant {
// Specific permission under test
// Specific permission under test
permission java.security.SerializablePermission "serialFilter";
permission java.security.SerializablePermission "serialFilter";
// Permissions needed to run the test
// Permissions needed to run the test
permission java.util.PropertyPermission "*", "read";
permission java.util.PropertyPermission "*", "read
,write
";
permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.security.SecurityPermission "*";
permission java.security.SecurityPermission "*";
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录