Skip to content

Commit

Permalink
tmf.core: Add auditable message confirming supplementary files were d…
Browse files Browse the repository at this point in the history
…eleted

Set to level Config to not fill the console.

[Security] Have an artifact proving when the supplementary files are cleaned

Change-Id: I7980e5a7cf7c82dd47abe32aa78b2ceac13766cc
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/201646
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
  • Loading branch information
MatthewKhouzam committed May 23, 2023
1 parent f0f09cb commit 4d4d2a3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Expand Up @@ -29,6 +29,8 @@
import java.util.Objects;
import java.util.Set;
import java.util.function.UnaryOperator;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import org.apache.commons.io.FileUtils;
Expand All @@ -44,6 +46,8 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils;
import org.eclipse.tracecompass.internal.tmf.core.Activator;
import org.eclipse.tracecompass.tmf.core.TmfCommonConstants;
import org.eclipse.tracecompass.tmf.core.signal.TmfEventFilterAppliedSignal;
Expand Down Expand Up @@ -92,6 +96,8 @@ public final class TmfTraceManager {

private static final String TEMP_DIR_NAME = ".tracecompass-temp"; //$NON-NLS-1$

private static final Logger LOGGER = TraceCompassLog.getLogger(TmfTraceManager.class);

// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
Expand Down Expand Up @@ -371,7 +377,10 @@ public static void refreshSupplementaryFiles(ITmfTrace trace) {
*/
public static void deleteSupplementaryFiles(ITmfTrace trace) {
try {
FileUtils.cleanDirectory(new File(TmfTraceManager.getSupplementaryFileDir(trace)));
String supplementaryFileDir = TmfTraceManager.getSupplementaryFileDir(trace);
FileUtils.cleanDirectory(new File(supplementaryFileDir));
// Needed to audit for privacy concerns
TraceCompassLogUtils.traceInstant(LOGGER, Level.CONFIG, "deleteSupplementaryFiles", supplementaryFileDir); //$NON-NLS-1$
} catch (IOException e) {
Activator.logError("Error deleting supplementary files for trace " + trace.getName(), e); //$NON-NLS-1$
}
Expand All @@ -390,7 +399,10 @@ public static void deleteSupplementaryFolder(ITmfTrace trace) {
deleteSupplementaryFiles(trace);
File parent = new File(TmfTraceManager.getSupplementaryFileDir(trace));
try {
deleteFolder(parent, getTemporaryDirPath());
String temporaryDirPath = getTemporaryDirPath();
deleteFolder(parent, temporaryDirPath);
// Needed to audit for privacy concerns
TraceCompassLogUtils.traceInstant(LOGGER, Level.CONFIG, "deleteSupplementaryFolder", temporaryDirPath); //$NON-NLS-1$
} catch (IOException e) {
Activator.logError("Error deleting supplementary folder for trace " + trace.getName(), e); //$NON-NLS-1$
}
Expand Down
Expand Up @@ -25,6 +25,8 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import org.eclipse.core.resources.IContainer;
Expand All @@ -46,6 +48,8 @@
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils;
import org.eclipse.tracecompass.internal.tmf.ui.Activator;
import org.eclipse.tracecompass.internal.tmf.ui.editors.ITmfEventsEditorConstants;
import org.eclipse.tracecompass.tmf.core.TmfCommonConstants;
Expand Down Expand Up @@ -77,6 +81,8 @@ public abstract class TmfCommonProjectElement extends TmfProjectModelElement {

private static final String BOOKMARKS_HIDDEN_FILE = ".bookmarks"; //$NON-NLS-1$

private static final @NonNull Logger LOGGER = TraceCompassLog.getLogger(TmfCommonProjectElement.class);

/* Direct child elements */
private TmfViewsElement fViewsElement = null;
private TmfOnDemandAnalysesElement fOnDemandAnalysesElement = null;
Expand Down Expand Up @@ -711,6 +717,8 @@ public void deleteSupplementaryResources(IResource[] resources) {
for (int i = 0; i < resources.length; i++) {
try {
resources[i].delete(true, new NullProgressMonitor());
// Needed to audit for privacy concerns
TraceCompassLogUtils.traceInstant(LOGGER, Level.CONFIG, "deleteSupplementaryResources", resources[i].getFullPath().toOSString() ); //$NON-NLS-1$
} catch (CoreException e) {
Activator.getDefault().logError("Error deleting supplementary resource " + resources[i], e); //$NON-NLS-1$
}
Expand Down

0 comments on commit 4d4d2a3

Please sign in to comment.