granted.add(new PropertyPermission("java.version", "read")); granted.add(new PropertyPermission("java.vendor", "read")); granted.add(new PropertyPermission("java.vendor.url", "read")); granted.add(new PropertyPermission("java.class.version", "read")); granted.add(new PropertyPermission("os.name", "read")); granted.add(new PropertyPermission("os.version", "read")); granted.add(new PropertyPermission("os.arch", "read")); granted.add(new PropertyPermission("file.encoding", "read")); granted.add(new PropertyPermission("file.separator", "read")); granted.add(new PropertyPermission("path.separator", "read")); granted.add(new PropertyPermission("line.separator", "read")); granted.add(new PropertyPermission("java.specification.version", "read")); granted.add(new PropertyPermission("java.specification.vendor", "read")); granted.add(new PropertyPermission("java.specification.name", "read")); granted.add(new PropertyPermission("java.vm.specification.version", "read")); granted.add(new PropertyPermission("java.vm.specification.vendor", "read")); granted.add(new PropertyPermission("java.vm.specification.name", "read")); granted.add(new PropertyPermission("java.vm.version", "read")); granted.add(new PropertyPermission("java.vm.vendor", "read")); granted.add(new PropertyPermission("java.vm.name", "read"));
public String run() { try { PropertyPermission pp = new PropertyPermission(name, "write"); pp.checkGuard(null); String o = System.getProperty(name); System.setProperty(name, value); SystemPropertyChange.INSTANCE.dispatchEvent(new PropertyChangeEvent(Thread.currentThread().getName(), name, o, value)); if (_debugSys) { System.out.println(log("system property updated : " + name + " new value : " + value, LVL.SYS_NOT, null)); } return null; } catch (SecurityException ex) { if (JXAenvUtils._debugSys) { ex.printStackTrace(); } return null; } } }, acc);
protected boolean checkPropertyPermission(PropertyPermission perm) { /* * TODO: this will need to be removed once REPLACE_CALLS * will be on by default */ if (perm.getName().equals("sun.font.fontmanager")) { return true; } if(perm.getActions().contains("write") && !executingTestCase) { if(org.evosuite.runtime.System.isSystemProperty(perm.getName())) { return false; } else { return true; } } return org.evosuite.runtime.System.handlePropertyPermission(perm); }
/** * Returns the "canonical string representation" of the actions. * That is, this method always returns present actions in the following order: * read, write. For example, if this PropertyPermission object * allows both write and read actions, a call to <code>getActions</code> * will return the string "read,write". * * @return the canonical string representation of the actions. */ public String getActions() { if (actions == null) actions= getActions(this.mask); return actions; }
if (perm.getActions().contains("write")) { if(isSystemProperty(perm.getName())) { String var = perm.getName();
private static boolean isPropertyAccess(final Permission perm) { if (!(perm instanceof PropertyPermission)) { return false; } final PropertyPermission propertyPermission = (PropertyPermission) perm; return propertyPermission.getActions().equals("read"); }
private static void checkPropertyWritePermission(Class<?> clazz, String propertyName) { final ProtectionDomain protectionDomain; final ClassLoader classLoader; if (getSecurityManager() instanceof WildFlySecurityManager) { protectionDomain = clazz.getProtectionDomain(); classLoader = clazz.getClassLoader(); } else { protectionDomain = doPrivileged(new GetProtectionDomainAction(clazz)); classLoader = doPrivileged(new GetClassLoaderAction(clazz)); } if (protectionDomain.implies(PROPERTIES_PERMISSION)) { return; } final PropertyPermission permission = new PropertyPermission(propertyName, "write"); if (protectionDomain.implies(permission)) { return; } access.accessCheckFailed(permission, protectionDomain.getCodeSource(), classLoader); if (! LOG_ONLY) { throw access.accessControlException(permission, permission, protectionDomain.getCodeSource(), classLoader); } }
String permissionName = p.getName(); if(deniedProperties != null && deniedProperties.contains(permissionName)) { throw new AccessControlException(ACCESS_DENIED_BASE + perm, perm); String actions = p.getActions();
private static void checkPropertyReadPermission(Class<?> clazz, String propertyName) { final ProtectionDomain protectionDomain; final ClassLoader classLoader; if (getSecurityManager() instanceof WildFlySecurityManager) { protectionDomain = clazz.getProtectionDomain(); classLoader = clazz.getClassLoader(); } else { protectionDomain = doPrivileged(new GetProtectionDomainAction(clazz)); classLoader = doPrivileged(new GetClassLoaderAction(clazz)); } if (protectionDomain.implies(PROPERTIES_PERMISSION)) { return; } final PropertyPermission permission = new PropertyPermission(propertyName, "read"); if (protectionDomain.implies(permission)) { return; } access.accessCheckFailed(permission, protectionDomain.getCodeSource(), classLoader); if (! LOG_ONLY) { throw access.accessControlException(permission, permission, protectionDomain.getCodeSource(), classLoader); } }
public void testForbiddenProperty() { String script = "System.getProperty(\"user.home\")"; assertExecute(script, null, new PropertyPermission("user.home", "read")); }
return; final PropertyPermission permission = new PropertyPermission(key, "read"); if (protectionDomain.implies(permission)) { return;
AccessControlContext acc = provider.getAccessControlContext(); try { acc.checkPermission(new PropertyPermission("*", "read")); fail("Acc should not have any permissions");
/** Returns a policy containing all the permissions we ever need. */ public static Policy permissivePolicy() { return new AdjustablePolicy // Permissions j.u.c. needs directly ( new RuntimePermission("modifyThread"), new RuntimePermission("getClassLoader"), new RuntimePermission("setContextClassLoader"), // Permissions needed to change permissions! new SecurityPermission("getPolicy"), new SecurityPermission("setPolicy"), new RuntimePermission("setSecurityManager"), // Permissions needed by the junit test harness new RuntimePermission("accessDeclaredMembers"), new PropertyPermission("*", "read"), new java.io.FilePermission("<<ALL FILES>>", "read")); }
/** * Returns a policy containing all the permissions we ever need. */ public static Policy permissivePolicy() { return new AdjustablePolicy // Permissions j.u.c. needs directly (new RuntimePermission("modifyThread"), new RuntimePermission("getClassLoader"), new RuntimePermission("setContextClassLoader"), // Permissions needed to change permissions! new SecurityPermission("getPolicy"), new SecurityPermission("setPolicy"), new RuntimePermission("setSecurityManager"), // Permissions needed by the junit test harness new RuntimePermission("accessDeclaredMembers"), new PropertyPermission("*", "read"), new java.io.FilePermission("<<ALL FILES>>", "read")); }
/** * Returns a policy containing all the permissions we ever need. */ public static Policy permissivePolicy() { return new AdjustablePolicy // Permissions j.u.c. needs directly (new RuntimePermission("modifyThread"), new RuntimePermission("getClassLoader"), new RuntimePermission("setContextClassLoader"), // Permissions needed to change permissions! new SecurityPermission("getPolicy"), new SecurityPermission("setPolicy"), new RuntimePermission("setSecurityManager"), // Permissions needed by the junit test harness new RuntimePermission("accessDeclaredMembers"), new PropertyPermission("*", "read"), new java.io.FilePermission("<<ALL FILES>>", "read")); }
public class MinimalPolicy extends Policy { private static PermissionCollection perms; public MinimalPolicy() { super(); if (perms == null) { perms = new MyPermissionCollection(); addPermissions(); } } @Override public PermissionCollection getPermissions(CodeSource codesource) { return perms; } private void addPermissions() { SocketPermission socketPermission = new SocketPermission("*:1024-", "connect, resolve"); PropertyPermission propertyPermission = new PropertyPermission("*", "read, write"); FilePermission filePermission = new FilePermission("<<ALL FILES>>", "read"); perms.add(socketPermission); perms.add(propertyPermission); perms.add(filePermission); } }
PropertyPermission propertyPermission = new PropertyPermission("javafx.macosx.embedded", "write");
public static String setProperty(String key, String value) { checkKey(key); SecurityManager sm = getSecurityManager(); if (sm != null) { sm.checkPermission(new PropertyPermission(key, SecurityConstants.PROPERTY_WRITE_ACTION)); } return (String) props.setProperty(key, value); }
public static String clearProperty(String key) { checkKey(key); SecurityManager sm = getSecurityManager(); if (sm != null) { sm.checkPermission(new PropertyPermission(key, "write")); } return (String) props.remove(key); }
public static synchronized void setDefault(Locale.Category category, Locale newLocale) { [...] SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new PropertyPermission("user.language", "write")); switch (category) { case DISPLAY: defaultDisplayLocale = newLocale; break; case FORMAT: defaultFormatLocale = newLocale; break; default: assert false: "Unknown Category"; } }