Search in sources :

Example 1 with Sanitizer

use of org.jboss.as.jdr.util.Sanitizer in project wildfly by wildfly.

the class AS7Plugin method getCommands.

@Override
public List<JdrCommand> getCommands() throws Exception {
    Sanitizer xmlSanitizer = Sanitizers.xml("//password");
    Sanitizer passwordSanitizer = Sanitizers.pattern("password=.*", "password=*");
    return Arrays.asList(new TreeCommand(), new JarCheck(), new CallAS7("configuration").param("recursive", "true"), new CallAS7("dump-services").operation("dump-services").resource("core-service", "service-container"), new CallAS7("cluster-proxies-configuration").resource("subsystem", "modcluster"), new CallAS7("jndi-view").operation("jndi-view").resource("subsystem", "naming"), new CollectFiles("*/standalone/configuration/*").sanitizer(xmlSanitizer, passwordSanitizer), new CollectFiles("*/domain/configuration/*").sanitizer(xmlSanitizer, passwordSanitizer), new CollectFiles("*server.log").limit(50 * Utils.ONE_MB), new CollectFiles("*.log").omit("*server.log"), new CollectFiles("*gc.log.*"), new CollectFiles("*.properties").sanitizer(passwordSanitizer), new CollectFiles("*.xml").sanitizer(xmlSanitizer), new CollectFiles("*/modules/system/*/.overlays/.overlays"), new CollectFiles("*/.installation/*.conf"), new CollectFiles("*/.installation/*.txt"), new SystemProperties().sanitizer(passwordSanitizer), new DeploymentDependencies(), new LocalModuleDependencies());
}
Also used : JarCheck(org.jboss.as.jdr.commands.JarCheck) CollectFiles(org.jboss.as.jdr.commands.CollectFiles) SystemProperties(org.jboss.as.jdr.commands.SystemProperties) Sanitizer(org.jboss.as.jdr.util.Sanitizer) CallAS7(org.jboss.as.jdr.commands.CallAS7) DeploymentDependencies(org.jboss.as.jdr.commands.DeploymentDependencies) TreeCommand(org.jboss.as.jdr.commands.TreeCommand) LocalModuleDependencies(org.jboss.as.jdr.commands.LocalModuleDependencies)

Example 2 with Sanitizer

use of org.jboss.as.jdr.util.Sanitizer in project wildfly by wildfly.

the class SystemProperties method execute.

@Override
public void execute() throws Exception {
    if (!this.env.isServerRunning())
        return;
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);
    Properties properties = System.getProperties();
    Enumeration<?> names = properties.propertyNames();
    while (names.hasMoreElements()) {
        String name = (String) names.nextElement();
        printWriter.println(name + "=" + properties.getProperty(name));
    }
    InputStream stream = new ByteArrayInputStream(stringWriter.toString().getBytes(StandardCharsets.UTF_8));
    for (Sanitizer sanitizer : this.sanitizers) {
        stream = sanitizer.sanitize(stream);
    }
    this.env.getZip().addAsString(stream, "system-properties.txt");
    Utils.safelyClose(stream);
}
Also used : StringWriter(java.io.StringWriter) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Sanitizer(org.jboss.as.jdr.util.Sanitizer) Properties(java.util.Properties) PrintWriter(java.io.PrintWriter)

Example 3 with Sanitizer

use of org.jboss.as.jdr.util.Sanitizer in project wildfly by wildfly.

the class CollectFiles method execute.

@Override
public void execute() throws Exception {
    VirtualFile root = VFS.getChild(this.env.getJbossHome());
    List<VirtualFile> matches = root.getChildrenRecursively(Filters.and(this.filter, this.blacklistFilter));
    // get some limit on that set, which probably would be wrong.
    if (sorter != null) {
        Collections.sort(matches, sorter);
    }
    // limit how much data we collect
    Limiter limiter = new Limiter(limit);
    Iterator<VirtualFile> iter = matches.iterator();
    while (iter.hasNext() && !limiter.isDone()) {
        VirtualFile f = iter.next();
        InputStream stream = limiter.limit(f);
        for (Sanitizer sanitizer : this.sanitizers) {
            if (sanitizer.accepts(f)) {
                stream = sanitizer.sanitize(stream);
            }
        }
        this.env.getZip().add(f, stream);
        Utils.safelyClose(stream);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) InputStream(java.io.InputStream) Sanitizer(org.jboss.as.jdr.util.Sanitizer)

Aggregations

Sanitizer (org.jboss.as.jdr.util.Sanitizer)3 InputStream (java.io.InputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Properties (java.util.Properties)1 CallAS7 (org.jboss.as.jdr.commands.CallAS7)1 CollectFiles (org.jboss.as.jdr.commands.CollectFiles)1 DeploymentDependencies (org.jboss.as.jdr.commands.DeploymentDependencies)1 JarCheck (org.jboss.as.jdr.commands.JarCheck)1 LocalModuleDependencies (org.jboss.as.jdr.commands.LocalModuleDependencies)1 SystemProperties (org.jboss.as.jdr.commands.SystemProperties)1 TreeCommand (org.jboss.as.jdr.commands.TreeCommand)1 VirtualFile (org.jboss.vfs.VirtualFile)1