Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to SafeLogging in org.apache.cassandra.streaming #592

Open
wants to merge 3 commits into
base: palantir-cassandra-2.2.18
Choose a base branch
from

Conversation

rhuffy
Copy link
Contributor

@rhuffy rhuffy commented Dec 5, 2024

Mark logging arguments as Safe or Unsafe in org.apache.cassandra.streaming.

This PR also wraps all calls to logger.debug() in an if (logger.isDebugEnabled()) check.

For reviewers, please confirm that you agree with my choices for SafeArgs.

Everything appears to be safe except

  • partitionKey in StreamReader

Interesting is the message variable in ConnectionHandler. I validated that these are safe by checking the toString methods of all subclasses of StreamMessage, but would appreciate a second look at this.

@@ -107,7 +109,7 @@ public void cleanup()
catch (Exception e)
{
JVMStabilityInspector.inspectThrowable(e);
logger.warn("failed to delete a potentially stale sstable {}", file);
logger.warn("failed to delete a potentially stale sstable {}", SafeArg.of("file", file));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the full file safeloggable ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from reading the above code, it appears that each line of the lockfile is a filename, called file that is passed to Descriptor.fromFilename.

Assuming that all sstable filenames are safe, then this log statement is safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switched to UnsafeArg

if (logger.isDebugEnabled())
logger.debug("[Stream #{}] Start streaming file {} to {}, repairedAt = {}, totalSize = {}",
SafeArg.of("planId", session.planId()),
SafeArg.of("file", sstable.getFilename()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also would like to doublecheck this is safe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sstable file names are safe right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah the filename is safe as long as it doesn't include the absolute path

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this could include the absolute path, so I'll mark it (and equivalents) as unsafe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switched to UnsafeArg

@@ -85,7 +88,7 @@ this class will not need to clean up tmp files (on restart), CassandraDaemon doe
}
catch (IOException e)
{
logger.warn(String.format("Could not create lockfile %s for stream session, nothing to worry too much about", lockfile), e);
logger.warn("Could not create lockfile {} for stream session, nothing to worry too much about", SafeArg.of("lockfile", lockfile.toString()), e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file marked as safe, inconsistent with the other files that i believe we've decided are unsafe

if (logger.isDebugEnabled())
logger.debug("[Stream #{}] Finished streaming file {} to {}, bytesTransferred = {}, totalSize = {}",
SafeArg.of("planId", session.planId()),
SafeArg.of("file", sstable.getFilename()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed one

if (logger.isDebugEnabled())
logger.debug("[Stream #{}] Start streaming file {} to {}, repairedAt = {}, totalSize = {}",
SafeArg.of("planId", session.planId()),
SafeArg.of("file", sstable.getFilename()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another

@rhuffy
Copy link
Contributor Author

rhuffy commented Dec 14, 2024

should be fixed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants