LarryRuane
commented at 8:58 pm on July 9, 2019:
contributor
When a developer is examining debug.log (or client terminal output), it’s often useful to know which RPCs have been submitted to the client; this can be enabled with the -debug=rpc configuration option. But this prints only the method name. This PR adds -debug=rpcparams to enable the logging of each RPC’s parameters (arguments). The parameters of certain RPCs are keys or passwords; these should not be logged.
I mean that it should go into a common module, probably ./src/util/ or similar.
DrahtBot
commented at 10:34 pm on July 9, 2019:
contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
Reviewers, this pull request conflicts with the following ones:
#22736 (log, sync: change lock contention from preprocessor directive to log category by jonatack)
#20487 (Add syscall sandboxing using seccomp-bpf (Linux secure computing mode) by practicalswift)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
DrahtBot added the label
Needs rebase
on Jul 9, 2019
fanquake added the label
RPC/REST/ZMQ
on Jul 10, 2019
fanquake added the label
Utils/log/libs
on Jul 10, 2019
promag
commented at 9:48 pm on July 10, 2019:
member
I’m undecided if a new category is needed, or just enable this additional logging with rpc. We don’t have many of the 32 category bits remaining (although we could easily change to use a uint64_t).
in
src/rpc/request.cpp:193
in
91ee96bd93outdated
188+ for (size_t i = 0; i < params.size(); ++i) {
189+ if (i > 0)
190+ LogPrint(BCLog::RPCPARAMS, ",");
191+ LogPrint(BCLog::RPCPARAMS, "%s", SanitizeString(params[i].getValStr()));
192+ }
193+ LogPrint(BCLog::RPCPARAMS, "]\n");
DrahtBot added the label
Needs rebase
on Aug 5, 2019
promag
commented at 2:04 pm on August 5, 2019:
member
Another approach is to add a sensitive options/flag (false by default) to RPCHelpManRPCArg.
LarryRuane force-pushed
on Aug 6, 2019
LarryRuane
commented at 6:19 am on August 6, 2019:
contributor
@promag, interesting idea, I like that it would allow specific arguments to be designated as sensitive, rather than the entire method. Also, it would be nice not to have to touch so many lines of code (as my latest commit does). But @instagibbs’s concern, #16365 (comment), which I was attempted to overcome with my latest commit, becomes live again.
DrahtBot removed the label
Needs rebase
on Aug 6, 2019
DrahtBot added the label
Needs rebase
on Aug 21, 2019
LarryRuane force-pushed
on Aug 22, 2019
LarryRuane
commented at 6:28 pm on August 22, 2019:
contributor
Rebased, replaced functional (python) test with a proper unit test.
DrahtBot removed the label
Needs rebase
on Aug 22, 2019
DrahtBot added the label
Needs rebase
on Sep 2, 2019
LarryRuane force-pushed
on Sep 2, 2019
DrahtBot removed the label
Needs rebase
on Sep 2, 2019
LarryRuane force-pushed
on Sep 2, 2019
LarryRuane
commented at 8:35 pm on September 2, 2019:
contributor
I had an idea for what may be an improvement. It’s in a separate commit, “replace sensitive bool with more general flags”. Please let me know what you think; this commit is optional.
Modifying all of the lines of the static const CRPCCommand commands[] tables is disruptive, and all that’s being done is to add a boolean value (to indicate whether to log the RPC’s params or not). As long as we’re touching all these lines anyway, why not implement a more general flags bitfield, of which DONTLOG is just the first bit. There may be other future attributes that would be useful to add to RPC methods. With this commit, adding them would touch only the lines corresponding to the affected RPCs, rather than all of them.
DrahtBot added the label
Needs rebase
on Sep 5, 2019
LarryRuane force-pushed
on Sep 5, 2019
DrahtBot removed the label
Needs rebase
on Sep 5, 2019
DrahtBot added the label
Needs rebase
on Sep 14, 2019
LarryRuane force-pushed
on Sep 15, 2019
DrahtBot removed the label
Needs rebase
on Sep 15, 2019
laanwj added the label
Feature
on Sep 30, 2019
DrahtBot added the label
Needs rebase
on Oct 30, 2019
LarryRuane force-pushed
on Nov 1, 2019
DrahtBot removed the label
Needs rebase
on Nov 1, 2019
DrahtBot added the label
Needs rebase
on Nov 5, 2019
LarryRuane force-pushed
on Nov 7, 2019
LarryRuane
commented at 9:08 pm on November 7, 2019:
contributor
Rebased to resolve conflicts.
DrahtBot removed the label
Needs rebase
on Nov 7, 2019
LarryRuane force-pushed
on Nov 21, 2019
LarryRuane
commented at 4:46 pm on November 22, 2019:
contributor
I don’t know the cause of the Travis CI failure; feature_pruning.py succeeds on my machine. I would not think this PR has any particular connection to that test. Maybe it’s a transient failure?
LarryRuane force-pushed
on Dec 14, 2019
DrahtBot added the label
Needs rebase
on Jan 9, 2020
LarryRuane force-pushed
on Jan 9, 2020
DrahtBot removed the label
Needs rebase
on Jan 10, 2020
LarryRuane closed this
on Jan 10, 2020
LarryRuane
commented at 3:33 pm on January 10, 2020:
contributor
Sorry, I accidentally closed this PR, reopening now…
LarryRuane reopened this
on Jan 10, 2020
LarryRuane force-pushed
on Jan 11, 2020
DrahtBot added the label
Needs rebase
on Feb 18, 2020
promag
commented at 11:24 pm on March 15, 2020:
member
Still not buying the approach.
How about disallow -debug=rpcparams in mainnet and drop the blacklist?
Couldn’t we use this approach for now?
LarryRuane
commented at 4:58 am on March 16, 2020:
contributor
Couldn’t we use this approach for now?
Just so I’m sure I understand, you’re suggesting not adding the flags member to CRPCCommand (here, which causes many lines to be touched, and that’s clearly undesirable), and instead just don’t censor anything (no black or white list), but restrict this to testnet only?
I like that idea, would make this PR much simpler. If it proves useful on testnet, then we can try to find an acceptable way to bring it to mainnet – maybe there’s a less intrusive way that’s still very safe. I always appreciate your comments.
sipa
commented at 5:46 pm on March 17, 2020:
member
So it seems everything depends on whether this is considered useful for mainnet. I can imagine that for production logging it is. If not, @promag’s approach is fine. If it is, the safest approach seems something like the current approach.
There is perhaps a less disruptive approach:
Make it possible to have an optional argument to the CRPCCommand constructors, which defaults to DONT_LOG, and not explicitly change it initially for any commands.
Then incrementally introduce DO_LOG flags, which can be done separately without needing to keep the whole PR up to date here.
One unrelated nit: I think it would be a bit cleaner to log the RPC command and arguments in the same log line (the logic would be something like if (debug_rpcparams && command.do_log) { log_rpc_with_params(); } else if (debug_rpc || debug_rpcparams) { log_rpc_without_params(); }
LarryRuane
commented at 1:59 am on March 18, 2020:
If testnet, always show the arguments.
LarryRuane
commented at 2:02 am on March 18, 2020:
contributor
Thanks, @sipa and @promag, I took both of your advice. The default now is to not log arguments on mainnet, and always log arguments on testnet. This change is now much less invasive.
DrahtBot removed the label
Needs rebase
on Mar 18, 2020
LarryRuane force-pushed
on Jul 13, 2020
DrahtBot added the label
Needs rebase
on Aug 12, 2020
LarryRuane force-pushed
on Aug 12, 2020
DrahtBot removed the label
Needs rebase
on Aug 12, 2020
DrahtBot added the label
Needs rebase
on Aug 13, 2020
LarryRuane force-pushed
on Sep 4, 2020
DrahtBot removed the label
Needs rebase
on Sep 4, 2020
DrahtBot added the label
Needs rebase
on Sep 15, 2020
LarryRuane force-pushed
on Sep 28, 2020
DrahtBot removed the label
Needs rebase
on Sep 28, 2020
LarryRuane renamed this:
Log RPC parameters (arguments) if -debug=rpcparams
[WIP] Log RPC parameters (arguments) if -debug=rpcparams
on Sep 29, 2020
LarryRuane force-pushed
on Sep 29, 2020
LarryRuane
commented at 6:05 am on September 29, 2020:
contributor
Force-pushed (diff) a different approach that does not require changing each of the 149 per-rpc CRPCCommand initializers. This new way is much less invasive and more manageable. I finally decided it’s best to go with an “allow” list (hard to beat simplicity). If someone adds a new RPC later without being aware of this form of logging, its arguments will not be logged. That makes this approach very safe against accidentally leaking secret information to the log file. I incorporated some of the review comments as well.
Here are some examples (without showing the RPC output):
As far as I can tell, these are the RPCs whose arguments shouldn’t be logged.
jonatack
commented at 11:10 am on August 19, 2021:
Maintainence of this list seems like a drawback. It would be nice if a test fails somewhere when an RPC is added or removed without the allow list being updated, e.g. with a list of structs of all the RPCs with an associated safe/unsafe bool value, or something like CRPCConvertParam. Feel to ignore if unrealistic.
DrahtBot added the label
Needs rebase
on Mar 2, 2021
LarryRuane force-pushed
on Mar 3, 2021
DrahtBot removed the label
Needs rebase
on Mar 3, 2021
DrahtBot added the label
Needs rebase
on Apr 5, 2021
LarryRuane force-pushed
on Apr 12, 2021
DrahtBot removed the label
Needs rebase
on Apr 12, 2021
DrahtBot added the label
Needs rebase
on Apr 27, 2021
Log RPC parameters if -debug=rpcparams7d22a6fad9
LarryRuane force-pushed
on Apr 29, 2021
DrahtBot removed the label
Needs rebase
on Apr 29, 2021
jonatack
commented at 11:55 am on August 19, 2021:
contributor
Tested almost-ACK7d22a6fad9d855e9dbb0bca70857c9aadc55f188 rebased to current master, modulo the comments below
LarryRuane
commented at 3:37 pm on August 20, 2021:
contributor
Maintenance of this list seems like a drawback
I agree, I’m going to convert this PR to draft because I think there’s a better way to do this that doesn’t require a separate list. I’ll also pick up your other suggestions. Thanks for taking the time to look it over!
LarryRuane marked this as a draft
on Aug 20, 2021
DrahtBot
commented at 11:19 pm on December 13, 2021:
contributor
🐙 This pull request conflicts with the target branch and needs rebase.
Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a “draft”.
DrahtBot added the label
Needs rebase
on Dec 13, 2021
DrahtBot
commented at 1:07 pm on March 21, 2022:
contributor
Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
Is it no longer relevant? ➡️ Please close.
Did the author lose interest or time to work on this? ➡️ Please close it and mark it ‘Up for grabs’ with the label, so that it can be picked up in the future.
fanquake
commented at 10:45 am on December 6, 2022:
member
I’m going to convert this PR to draft because I think there’s a better way to do this that doesn’t require a separate list. I’ll also pick up your other suggestions.
Given it’s been 16 months this statement, I’m going to close this for now. Feel free to comment / ping if you’re going to work on this again and need the PR reopened.
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2024-11-17 03:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me