Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make audit-argument-checks into an empty package, detected via weak d…

…eps.

This requires making sure that empty packages work!
  • Loading branch information...
commit 37e2cc4deede5aa5cf9f47bbd14c5b1d981a0892 1 parent 9755f54
@glasser glasser authored
View
1  packages/audit-argument-checks/audit_argument_checks.js
@@ -1 +0,0 @@
-DDPServer._setAuditArgumentChecks(true);
View
5 packages/audit-argument-checks/package.js
@@ -2,7 +2,4 @@ Package.describe({
summary: "Try to detect inadequate input sanitization"
});
-Package.on_use(function (api) {
- api.use(['livedata'], ['server']);
- api.add_files(['audit_argument_checks.js'], 'server');
-});
+// This package is empty; its presence is detected by livedata.
View
10 packages/livedata/livedata_server.js
@@ -1368,16 +1368,12 @@ var wrapInternalException = function (exception, context) {
return new Meteor.Error(500, "Internal server error");
};
-// Private interface for 'audit-argument-checks' package.
-//
-var shouldAuditArgumentChecks = false;
-DDPServer._setAuditArgumentChecks = function (value) {
- shouldAuditArgumentChecks = value;
-};
+// Audit argument checks, if the audit-argument-checks package exists (it is a
+// weak dependency of this package).
var maybeAuditArgumentChecks = function (f, context, args, description) {
args = args || [];
- if (shouldAuditArgumentChecks) {
+ if (Package['audit-argument-checks']) {
return Match._failIfArgumentsAreNotAllChecked(
f, context, args, description);
}
View
3  packages/livedata/package.js
@@ -16,6 +16,9 @@ Package.on_use(function (api) {
// XXX split this package into multiple packages or multiple slices instead
api.use(['webapp', 'routepolicy'], 'server', {weak: true});
+ // Detect whether or not the user wants us to audit argument checks.
+ api.use(['audit-argument-checks'], 'server', {weak: true});
+
api.exportSymbol('DDP');
api.exportSymbol('DDPServer', 'server');
View
9 tools/linker.js
@@ -94,7 +94,14 @@ _.extend(Module.prototype, {
getPrelinkedFiles: function () {
var self = this;
- if (! self.files.length)
+ // If there are no files *and* we are a no-exports-at-all slice (eg a test
+ // slice), then generate no prelink output.
+ //
+ // If there are no files, but we are a use slice (and thus self.exports is
+ // an actual, albeit potentially empty, list), we DON'T want to take this
+ // path: we want to return an empty prelink file, so that at link time we
+ // end up at least setting `Package.foo = {}`.
+ if (_.isEmpty(self.files) && !self.exports)
return [];
// If we don't want to create a separate scope for this module,
Please sign in to comment.
Something went wrong with that request. Please try again.