Skip to content

Commit

Permalink
Rename onFileLoaded method
Browse files Browse the repository at this point in the history
  • Loading branch information
jandro996 committed Sep 12, 2024
1 parent d8c8b1b commit 7a6cea9
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,18 @@ private static void iastCallback(URI uri) {
}

private static void raspCallback(File parent, String child) {
FileLoadedRaspHelper.INSTANCE.onFileLoaded(parent, child);
FileLoadedRaspHelper.INSTANCE.beforeFileLoaded(parent, child);
}

private static void raspCallback(String parent, String file) {
FileLoadedRaspHelper.INSTANCE.onFileLoaded(parent, file);
FileLoadedRaspHelper.INSTANCE.beforeFileLoaded(parent, file);
}

private static void raspCallback(String s) {
FileLoadedRaspHelper.INSTANCE.onFileLoaded(s);
FileLoadedRaspHelper.INSTANCE.beforeFileLoaded(s);
}

private static void raspCallback(URI uri) {
FileLoadedRaspHelper.INSTANCE.onFileLoaded(uri);
FileLoadedRaspHelper.INSTANCE.beforeFileLoaded(uri);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ private static void iastCallback(String path) {
}

private static void raspCallback(String path) {
FileLoadedRaspHelper.INSTANCE.onFileLoaded(path);
FileLoadedRaspHelper.INSTANCE.beforeFileLoaded(path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ private FileLoadedRaspHelper() {
// prevent instantiation
}

public void onFileLoaded(@Nullable final String parent, @Nonnull final String child) {
public void beforeFileLoaded(@Nullable final String parent, @Nonnull final String child) {
try {
if (parent == null) {
onFileLoaded(child);
beforeFileLoaded(child);
return;
}
String s = parent + FileSystems.getDefault().getSeparator() + child;
onFileLoaded(s);
beforeFileLoaded(s);
} catch (final BlockingException e) {
// re-throw blocking exceptions
throw e;
Expand All @@ -46,14 +46,14 @@ public void onFileLoaded(@Nullable final String parent, @Nonnull final String ch
}
}

public void onFileLoaded(@Nonnull final String first, @Nonnull final String[] more) {
public void beforeFileLoaded(@Nonnull final String first, @Nonnull final String[] more) {
try {
String separator = FileSystems.getDefault().getSeparator();
String s = first;
if (more.length > 0) {
s += separator + String.join(separator, more);
}
onFileLoaded(s);
beforeFileLoaded(s);
} catch (final BlockingException e) {
// re-throw blocking exceptions
throw e;
Expand All @@ -63,9 +63,9 @@ public void onFileLoaded(@Nonnull final String first, @Nonnull final String[] mo
}
}

public void onFileLoaded(@Nonnull final URI uri) {
public void beforeFileLoaded(@Nonnull final URI uri) {
try {
onFileLoaded(uri.toString());
beforeFileLoaded(uri.toString());
} catch (final BlockingException e) {
// re-throw blocking exceptions
throw e;
Expand All @@ -75,14 +75,14 @@ public void onFileLoaded(@Nonnull final URI uri) {
}
}

public void onFileLoaded(@Nullable final File parent, @Nonnull final String child) {
public void beforeFileLoaded(@Nullable final File parent, @Nonnull final String child) {
try {
if (parent == null) {
onFileLoaded(child);
beforeFileLoaded(child);
return;
}
String s = parent + FileSystems.getDefault().getSeparator() + child;
onFileLoaded(s);
beforeFileLoaded(s);
} catch (final BlockingException e) {
// re-throw blocking exceptions
throw e;
Expand All @@ -92,7 +92,7 @@ public void onFileLoaded(@Nullable final File parent, @Nonnull final String chil
}
}

public void onFileLoaded(@Nonnull final String path) {
public void beforeFileLoaded(@Nonnull final String path) {
if (!Config.get().isAppSecRaspEnabled()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ private static void iastCallback(String path) {
}

private static void raspCallback(String path) {
FileLoadedRaspHelper.INSTANCE.onFileLoaded(path);
FileLoadedRaspHelper.INSTANCE.beforeFileLoaded(path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ private static void iastCallback(String other) {
}

private static void raspCallback(String other) {
FileLoadedRaspHelper.INSTANCE.onFileLoaded(other);
FileLoadedRaspHelper.INSTANCE.beforeFileLoaded(other);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ private static void iastCallback(String first, String[] more) {
}

private static void raspCallback(String first, String[] more) {
FileLoadedRaspHelper.INSTANCE.onFileLoaded(first, more);
FileLoadedRaspHelper.INSTANCE.beforeFileLoaded(first, more);
}

private static void raspCallback(URI uri) {
FileLoadedRaspHelper.INSTANCE.onFileLoaded(uri);
FileLoadedRaspHelper.INSTANCE.beforeFileLoaded(uri);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class FileCallSiteTest extends BaseIoRaspCallSiteTest {
TestFileSuite.newFile(parent, child)

then:
1 * helper.onFileLoaded(parent, child)
1 * helper.beforeFileLoaded(parent, child)
}

void 'test RASP new file with parent file and child'() {
Expand All @@ -107,7 +107,7 @@ class FileCallSiteTest extends BaseIoRaspCallSiteTest {
TestFileSuite.newFile(parent, child)

then:
1 * helper.onFileLoaded(parent, child)
1 * helper.beforeFileLoaded(parent, child)
}

void 'test RASP new file with uri'() {
Expand All @@ -120,6 +120,6 @@ class FileCallSiteTest extends BaseIoRaspCallSiteTest {
TestFileSuite.newFile(file)

then:
1 * helper.onFileLoaded(file)
1 * helper.beforeFileLoaded(file)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ class FileInputStreamCallSiteTest extends BaseIoRaspCallSiteTest {
TestFileInputStreamSuite.newFileInputStream(path)

then:
1 * helper.onFileLoaded(path)
1 * helper.beforeFileLoaded(path)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FileLoadedRaspHelperForkedTest extends BaseIoRaspCallSiteTest {
tracer.getCallbackProvider(RequestContextSlot.APPSEC) >> callbackProvider

when:
FileLoadedRaspHelper.INSTANCE."onFileLoaded"(*args)
FileLoadedRaspHelper.INSTANCE.beforeFileLoaded(*args)

then:
1 * callbackProvider.getCallback(EVENTS.fileLoaded()) >> listener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FileOutputStreamCallSiteTest extends BaseIoRaspCallSiteTest {
TestFileOutputStreamSuite.newFileOutputStream(path)

then:
1 * helper.onFileLoaded(path)
1 * helper.beforeFileLoaded(path)
}

void 'test RASP new file input stream with path and append'() {
Expand All @@ -58,6 +58,6 @@ class FileOutputStreamCallSiteTest extends BaseIoRaspCallSiteTest {
TestFileOutputStreamSuite.newFileOutputStream(path, false)

then:
1 * helper.onFileLoaded(path)
1 * helper.beforeFileLoaded(path)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PathCallSiteTest extends BaseIoRaspCallSiteTest {
TestPathSuite.resolve(getRootFolder().toPath(), path)

then:
1 * helper.onFileLoaded(path)
1 * helper.beforeFileLoaded(path)
}

void 'test RASP resolve sibling'() {
Expand All @@ -58,6 +58,6 @@ class PathCallSiteTest extends BaseIoRaspCallSiteTest {
TestPathSuite.resolveSibling(sibling, path)

then:
1 * helper.onFileLoaded(path)
1 * helper.beforeFileLoaded(path)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PathsCallSiteTest extends BaseIoRaspCallSiteTest {
TestPathsSuite.get(first, other)

then:
1 * helper.onFileLoaded(first, other)
1 * helper.beforeFileLoaded(first, other)

where:
first | other
Expand All @@ -64,6 +64,6 @@ class PathsCallSiteTest extends BaseIoRaspCallSiteTest {
TestPathsSuite.get(file)

then:
1 * helper.onFileLoaded(file)
1 * helper.beforeFileLoaded(file)
}
}

0 comments on commit 7a6cea9

Please sign in to comment.