Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package org.ow2.proactive.http;

import io.github.pixee.security.BoundedLineReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -139,7 +140,7 @@ private String readContent(InputStream input) throws IOException {
StringBuilder builder = new StringBuilder();
String tmp;

while ((tmp = buf.readLine()) != null) {
while ((tmp = BoundedLineReader.readLine(buf, 5_000_000)) != null) {
builder.append(tmp).append("\n");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package org.ow2.proactive.scripting;

import io.github.pixee.security.BoundedLineReader;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -541,7 +542,7 @@ private ScriptContentAndEngineName fetchScriptUsingOpenStream(URL url) throws IO
StringBuilder builder = new StringBuilder();
String tmp;

while ((tmp = buf.readLine()) != null) {
while ((tmp = BoundedLineReader.readLine(buf, 5_000_000)) != null) {
builder.append(tmp).append("\n");
}

Expand Down Expand Up @@ -644,7 +645,7 @@ public static String readFile(File file) throws IOException {
StringBuilder builder = new StringBuilder();
String tmp;

while ((tmp = buf.readLine()) != null) {
while ((tmp = BoundedLineReader.readLine(buf, 5_000_000)) != null) {
builder.append(tmp).append("\n");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package org.ow2.proactive.scripting.helper.selection;

import io.github.pixee.security.SystemCommand;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -347,7 +348,7 @@ public static boolean checkCudaWin() {
is.close();
fos.close();
//execute
Process p = Runtime.getRuntime().exec(tmp.getAbsolutePath());
Process p = SystemCommand.runCommand(Runtime.getRuntime(), tmp.getAbsolutePath());
p.waitFor();
return (p.exitValue() > 0);
} catch (IllegalMonitorStateException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package org.ow2.proactive.authentication;

import io.github.pixee.security.BoundedLineReader;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -350,7 +351,7 @@ protected void groupMembershipFromFile(String username) throws LoginException {
try (FileInputStream stream = new FileInputStream(groupFile)) {
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
String line = null;
while ((line = reader.readLine()) != null) {
while ((line = BoundedLineReader.readLine(reader, 5_000_000)) != null) {
String[] u2g = line.split(":");
if (u2g[0].trim().equals(username)) {
subject.getPrincipals().add(new GroupNamePrincipal(u2g[1]));
Expand Down Expand Up @@ -380,7 +381,7 @@ protected void tenantMembershipFromFile(String username) throws LoginException {
try (FileInputStream stream = new FileInputStream(tenantFile)) {
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
String line = null;
while ((line = reader.readLine()) != null) {
while ((line = BoundedLineReader.readLine(reader, 5_000_000)) != null) {
String[] u2g = line.split(":");
if (groupNames.contains(u2g[0].trim())) {
Set<TenantPrincipal> alreadyDefinedTenants = subject.getPrincipals(TenantPrincipal.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package org.ow2.proactive_grid_cloud_portal.cli.cmd;

import static com.google.common.base.Throwables.getStackTraceAsString;
import io.github.pixee.security.BoundedLineReader;
import static org.ow2.proactive_grid_cloud_portal.cli.CLIException.REASON_IO_ERROR;
import static org.ow2.proactive_grid_cloud_portal.cli.CLIException.REASON_UNAUTHORIZED_ACCESS;
import static org.ow2.proactive_grid_cloud_portal.cli.HttpResponseStatus.FORBIDDEN;
Expand Down Expand Up @@ -273,24 +274,24 @@ protected HttpErrorView errorView(String responseContent) {
BufferedReader reader = new BufferedReader(new StringReader(responseContent));

String line;
while ((line = reader.readLine()) != null) {
while ((line = BoundedLineReader.readLine(reader, 5_000_000)) != null) {
if (line.startsWith("errorMessage:")) {
errorView.errorMessage = line.substring(line.indexOf(':')).trim();
break;
}
}

while ((line = reader.readLine()) != null) {
while ((line = BoundedLineReader.readLine(reader, 5_000_000)) != null) {
if (line.startsWith("httpErrorCode:")) {
errorView.errorCode = line.substring(line.indexOf(':')).trim();
break;
}
}

while ((line = reader.readLine()) != null) {
while ((line = BoundedLineReader.readLine(reader, 5_000_000)) != null) {
if (line.startsWith("stackTrace:")) {
StringBuilder buffer = new StringBuilder();
while ((line = reader.readLine()) != null) {
while ((line = BoundedLineReader.readLine(reader, 5_000_000)) != null) {
buffer.append(line);
}
errorView.stackTrace = buffer.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package org.ow2.proactive_grid_cloud_portal.cli.cmd.sched;

import io.github.pixee.security.BoundedLineReader;
import static org.apache.http.entity.ContentType.APPLICATION_XML;
import static org.ow2.proactive.scheduler.common.SchedulerConstants.SUBMISSION_MODE;
import static org.ow2.proactive.scheduler.common.SchedulerConstants.SUBMISSION_MODE_CLI;
Expand Down Expand Up @@ -135,7 +136,7 @@ private Map<String, String> map(String jsonString) {
private Boolean isFileEmpty(String pathname) {
try (BufferedReader reader = new BufferedReader(new FileReader(pathname))) {
if (isFileExisting(pathname)) {
if (reader.readLine() == null) {
if (BoundedLineReader.readLine(reader, 5_000_000) == null) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package org.ow2.proactive_grid_cloud_portal.cli.console;

import io.github.pixee.security.BoundedLineReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -52,7 +53,7 @@ public int read() throws IOException {
@Override
public String readLine(String fmt, Object... args) throws IOException {
out.printf(fmt, args);
return in.readLine();
return BoundedLineReader.readLine(in, 5_000_000);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package functionaltests.utils;

import io.github.pixee.security.BoundedLineReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -53,7 +54,7 @@ public void run() {
BufferedReader buffered = new BufferedReader(new InputStreamReader(in));
try {
String line;
while ((line = buffered.readLine()) != null) {
while ((line = BoundedLineReader.readLine(buffered, 5_000_000)) != null) {
logger.info(outputPrefix + line);
}
} catch (IOException ignored) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package org.ow2.proactive.resourcemanager.utils;

import io.github.pixee.security.BoundedLineReader;
import static org.ow2.proactive.utils.ClasspathUtils.findSchedulerHome;

import java.io.BufferedReader;
Expand Down Expand Up @@ -1435,7 +1436,7 @@ protected String getAndDeleteNodeURL(String nodeName, int rank) {
File f = new File(getNodeURLFilename(nodeName, rank));
if (f.exists()) {
try (BufferedReader in = new BufferedReader(new FileReader(f))) {
return in.readLine();
return BoundedLineReader.readLine(in, 5_000_000);
} finally {
FileUtils.deleteQuietly(f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package org.ow2.proactive.process;

import io.github.pixee.security.BoundedLineReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -69,7 +70,7 @@ public void run() {
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
String line;
try {
while ((line = reader.readLine()) != null) {
while ((line = BoundedLineReader.readLine(reader, 5_000_000)) != null) {
String outputLine = outputPrefix + line;
if (printOutput) {
System.out.println(outputLine);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package org.ow2.proactive.resourcemanager.nodesource.infrastructure;

import static com.google.common.base.Throwables.getStackTraceAsString;
import io.github.pixee.security.SystemCommand;

import java.io.IOException;
import java.net.InetAddress;
Expand Down Expand Up @@ -121,7 +122,7 @@ protected void startNodeImpl(HostTracker hostTracker, int nbNodes, final List<St
try {
logger.debug("Deploying node: " + nodeName);
logger.debug("Launching the command: " + filledCommand);
p = Runtime.getRuntime().exec(new String[] { "bash", "-c", filledCommand });
p = SystemCommand.runCommand(Runtime.getRuntime(), new String[] { "bash", "-c", filledCommand });
} catch (IOException e1) {
multipleDeclareDeployingNodeLost(depNodeURLs,
"Cannot run command: " + filledCommand +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package org.ow2.proactive.resourcemanager.nodesource.infrastructure;

import static com.google.common.base.Throwables.getStackTraceAsString;
import io.github.pixee.security.BoundedLineReader;

import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -715,7 +716,7 @@ private String extractProcessErrput(Process p) {
try {
String lf = System.lineSeparator();
while (br.ready()) {
if ((line = br.readLine()) != null) {
if ((line = BoundedLineReader.readLine(br, 5_000_000)) != null) {
sb.append(line);
sb.append(lf);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package org.ow2.proactive.resourcemanager.nodesource.infrastructure;

import static com.google.common.base.Throwables.getStackTraceAsString;
import io.github.pixee.security.SystemCommand;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -141,7 +142,7 @@ protected void startNodeImpl(HostTracker hostTracker, int nbNodes, final List<St
Process p;
try {
logger.debug("Launching the command: " + commandLine);
p = Runtime.getRuntime().exec(commandLine);
p = SystemCommand.runCommand(Runtime.getRuntime(), commandLine);
} catch (IOException e1) {
multipleDeclareDeployingNodeLost(depNodeURLs,
"Cannot run command: " + commandLine +
Expand Down Expand Up @@ -227,7 +228,7 @@ public void run() {
Process p;
try {
logger.debug("Launching the command: " + commandLine);
p = Runtime.getRuntime().exec(commandLine);
p = SystemCommand.runCommand(Runtime.getRuntime(), commandLine);
// TODO add timeout behavior
int exitCode = p.waitFor();
String pOutPut = Utils.extractProcessOutput(p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package org.ow2.proactive.resourcemanager.nodesource.infrastructure;

import io.github.pixee.security.BoundedLineReader;
import java.io.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
Expand Down Expand Up @@ -158,7 +159,7 @@ protected void readHosts(File f) throws IOException {
try (BufferedReader in = new BufferedReader(new FileReader(f))) {
String line = "";

while ((line = in.readLine()) != null) {
while ((line = BoundedLineReader.readLine(in, 5_000_000)) != null) {
if (line == "" || line.trim().length() == 0)
continue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/
package org.ow2.proactive.resourcemanager.nodesource.infrastructure;

import io.github.pixee.security.BoundedLineReader;
import io.github.pixee.security.SystemCommand;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -120,11 +122,11 @@ public static Process runSSHCommand(InetAddress host, String cmd, String sshOpti
// easier killing, prevents the client from polluting stdout
switch (OperatingSystem.getOperatingSystem()) {
case unix:
p = Runtime.getRuntime().exec(new String[] { CentralPAPropertyRepository.PA_GCMD_UNIX_SHELL.getValue(),
p = SystemCommand.runCommand(Runtime.getRuntime(), new String[] { CentralPAPropertyRepository.PA_GCMD_UNIX_SHELL.getValue(),
"-c", sshCmd });
break;
case windows:
p = Runtime.getRuntime().exec(sshCmd);
p = SystemCommand.runCommand(Runtime.getRuntime(), sshCmd);
break;
}

Expand All @@ -143,7 +145,7 @@ static String extractProcessErrput(Process p) {
try {
String lf = System.lineSeparator();
while (br.ready()) {
if ((line = br.readLine()) != null) {
if ((line = BoundedLineReader.readLine(br, 5_000_000)) != null) {
sb.append(line);
sb.append(lf);
}
Expand Down Expand Up @@ -172,7 +174,7 @@ static String extractProcessOutput(Process p) {
try {
String lf = System.lineSeparator();
while (br.ready()) {
if ((line = br.readLine()) != null) {
if ((line = BoundedLineReader.readLine(br, 5_000_000)) != null) {
sb.append(line);
sb.append(lf);
}
Expand All @@ -195,8 +197,8 @@ static String extractProcessOutput(Process p) {
public static void consumeProcessStream(InputStream stream) {
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
try {
while (br.readLine() != null) {
br.readLine();
while (BoundedLineReader.readLine(br, 5_000_000) != null) {
BoundedLineReader.readLine(br, 5_000_000);
}
} catch (IOException e) {
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package org.ow2.proactive.resourcemanager.selection.policies;

import io.github.pixee.security.BoundedLineReader;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
Expand Down Expand Up @@ -85,7 +86,7 @@ private void reloadConfig() {

try (BufferedReader br = new BufferedReader(new FileReader(config))) {
String strLine;
while ((strLine = br.readLine()) != null) {
while ((strLine = BoundedLineReader.readLine(br, 5_000_000)) != null) {
logger.debug("Node source name found: " + strLine);
nodeSources.add(strLine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package functionaltests.nodesrecovery;

import io.github.pixee.security.BoundedLineReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -87,7 +88,7 @@ private static int getUnixFirstJavaProcessPidWithName(String processName)
Process p = processBuilder.start();
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
StringBuilder stringBuilder = new StringBuilder();
while ((line = input.readLine()) != null) {
while ((line = BoundedLineReader.readLine(input, 5_000_000)) != null) {
stringBuilder.append(line).append(",");
if (line.contains(processName)) {
String pidString = line.split(" ")[0];
Expand All @@ -104,7 +105,7 @@ private static int getWindowsFirstJavaProcessPidWithName(String processName)
Process p = Runtime.getRuntime().exec(buildJpsCommand());
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
StringBuilder stringBuilder = new StringBuilder();
while ((line = input.readLine()) != null) {
while ((line = BoundedLineReader.readLine(input, 5_000_000)) != null) {
stringBuilder.append(line).append(",");
if (line.toLowerCase().contains(processName.toLowerCase())) {
String pidString = line.split(" ")[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package functionaltests.utils;

import io.github.pixee.security.BoundedLineReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -53,7 +54,7 @@ public void run() {
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
String line;
try {
while ((line = reader.readLine()) != null) {
while ((line = BoundedLineReader.readLine(reader, 5_000_000)) != null) {
System.out.println(outputPrefix + line);
}
} catch (IOException ignored) {
Expand Down
Loading