-
Notifications
You must be signed in to change notification settings - Fork 215
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
Distressing proliferation of ambient authority #2160
Comments
I'd like to see "do not export powerful objects" on a code review checklist. It's one thing to import Do we have a code review checklist? By way of example: https://informatics.kumc.edu/work/wiki/CodeReviewNotes For cleaning up existing code, lavamoat would let us detect use of ambient authority in many / most cases, I suppose. Strictly speaking, I don't think this constitutes a bug, since I don't see any incorrect observable behavior identified. In KUMC Informatics, we would label this as technical-debt and review the list of such issues every few weeks in a QA meeting. Making time to pay off technical debt in the schedule when it competes with observable bugs and features is a challenge, but one that healthy teams eventually deal with. |
For what it is worth, the deploy scripts are taking local files and bundling and deploying them, so they must have the ability to read parts of the filesystem. |
Yes, but shouldn't that access to the filesystem be passed in explicitly? I don't see any particular reason why deployApi, which is exported, should close over ambient access to |
Hi @dckc so far you've been our most effective conscience getting us to clean up our act on this. Ok if I assign it to you? Not that I'm asking you to do this but rather to get people to do this for the code they're responsible for. |
If you'll clarify the "finish line" a bit, I'm fine if you assign it to me. Above I proposed "do not export powerful objects"; is that a good target / finish line? |
If someone is just using an ambient The finish line is when you've sufficiently habituated everyone else that we are all sensitive to it and reliably complain about it in code reviews. I don't know how to fit that into the goal of closing an issue, but it is what we must do. Adding @rowgraus to the assignees for that process issue. Suggestion: you coordinate with @rowgraus . You get all this started until he feels like he can take the process forward from there. |
I leave that to the two of you. |
While I've been worrying about and asking for feedback on how to thread configuration options to // eslint-disable-next-line no-redeclare
/* global process */ indicating that eslint considers this declaration a redeclaration. Where is the base declaration and how do we turn it off? |
One lesson I learned at Google is that an organization is much more likely to make incremental progress to a goal if it can turn it into a metric. We've been planning for a closer integration with LavaMoat anyway. It seems we need to do this sooner rather than later so that we can track all of these proliferating uses of ambient authority, understand where they all are, take inventory, identify the worst offenders to fix quickly, and then start making incremental but rapid progress on reducing the remainder. |
Hi @kumavis we need to start integrating LavaMoat into our own development process. In its absence, we've let uses of ambient authority proliferate. |
This concern is already on our https://github.com/Agoric/agoric-sdk/wiki/Code-Review-Checklist . We need to start applying it. |
Btw, I have made this mistake too. fatal-assert.js uses |
I recognize the danger of ambient authority. IIUC, many uses of it just need to be moved up to the script main entrypoint and propagated explicitly to other modules. We should have conventions for that entrypoint's name, such as |
In endojs/endo#715 (comment) @erights writes re
I was thinking this is infeasible to check, but that's pretty much exactly what LavaMoat does, isn't it? Anybody got a pointer to how? @kriskowal @kumavis ? |
@warner writes in #3207 (comment) :
A "main" that should execute in a scope with lots of authority is indicated by I'm not sure to what extent the team has adopted this rule, but @erights writes Mar 7 in #2160 (comment) :
He also notes lack of tool support in #2160 (comment) and utility of metrics to track progress in #2160 (comment) I hope to try out lavamoat to establish a metric. |
An interesting tool to look for global mutable state is Moddable's It's currently commented out, but that's easy to address if you want to play around with it a bit: diff --git a/xsnap/sources/xsnap.c b/xsnap/sources/xsnap.c
index 6389db2..4589083 100644
--- a/xsnap/sources/xsnap.c
+++ b/xsnap/sources/xsnap.c
@@ -375,14 +375,14 @@ void xsBuildAgent(xsMachine* machine)
modInstallTextEncoder(the);
modInstallBase64(the);
//
-// xsResult = xsNewHostFunction(fx_harden, 1);
-// xsDefine(xsGlobal, xsID("harden"), xsResult, xsDontEnum);
-// xsResult = xsNewHostFunction(xs_lockdown, 0);
-// xsDefine(xsGlobal, xsID("lockdown"), xsResult, xsDontEnum);
-// xsResult = xsNewHostFunction(fx_petrify, 1);
-// xsDefine(xsGlobal, xsID("petrify"), xsResult, xsDontEnum);
-// xsResult = xsNewHostFunction(fx_mutabilities, 1);
-// xsDefine(xsGlobal, xsID("mutabilities"), xsResult, xsDontEnum);
+ xsResult = xsNewHostFunction(fx_harden, 1);
+ xsDefine(xsGlobal, xsID("harden"), xsResult, xsDontEnum);
+ xsResult = xsNewHostFunction(xs_lockdown, 0);
+ xsDefine(xsGlobal, xsID("lockdown"), xsResult, xsDontEnum);
+ xsResult = xsNewHostFunction(fx_petrify, 1);
+ xsDefine(xsGlobal, xsID("petrify"), xsResult, xsDontEnum);
+ xsResult = xsNewHostFunction(fx_mutabilities, 1);
+ xsDefine(xsGlobal, xsID("mutabilities"), xsResult, xsDontEnum);
xsEndHost(machine);
} |
could make an eslint rule that gets angry when you import builtin modules |
+:100: to automating whatever the policy is. We don't even need a new rule if we're content with listing the most problematic: https://eslint.org/docs/latest/rules/no-restricted-imports Then we can use the tooling to partition paths in which is really is a problem to import these from those were it's not. E.g. CLI tools. |
LavaMoat-like techniques are starting to look feasible: LavaMoat/LavaMoat#228 (comment) here's hoping for time to dig in more... |
A simple search
shows 26 modules (!!) in agoric-sdk importing
from 'fs';
after filtering out tests and demo code. What other sources of ambient authority are we using? How should we detect/prevent/warn on these by default? How should we override that default for the (should be) rare resource module that should directly access ambient authority?Attn @dckc
The text was updated successfully, but these errors were encountered: