@contrast/agent 4.4.1 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/bin/VERSION +1 -1
  2. package/bin/linux/contrast-service +0 -0
  3. package/bin/mac/contrast-service +0 -0
  4. package/bin/windows/contrast-service.exe +0 -0
  5. package/lib/assess/hapi/route-coverage.js +3 -3
  6. package/lib/assess/membrane/index.js +2 -8
  7. package/lib/assess/membrane/source-membrane.js +3 -4
  8. package/lib/assess/models/base-event.js +2 -2
  9. package/lib/assess/models/call-context.js +0 -3
  10. package/lib/assess/policy/propagators.json +20 -0
  11. package/lib/assess/policy/signatures.json +103 -0
  12. package/lib/assess/propagators/path/common.js +165 -36
  13. package/lib/assess/propagators/path/join.js +5 -1
  14. package/lib/assess/propagators/path/normalize.js +5 -1
  15. package/lib/assess/propagators/path/resolve.js +11 -2
  16. package/lib/assess/response-scanning/autocomplete-missing.js +0 -2
  17. package/lib/assess/response-scanning/parameter-pollution.js +0 -2
  18. package/lib/core/arch-components/dynamodb.js +1 -2
  19. package/lib/core/arch-components/dynamodbv3.js +44 -0
  20. package/lib/core/arch-components/index.js +1 -0
  21. package/lib/core/async-storage/hooks/bluebird.js +20 -0
  22. package/lib/core/config/options.js +3 -2
  23. package/lib/core/express/utils.js +1 -1
  24. package/lib/core/logger/debug-logger.js +15 -17
  25. package/lib/core/stacktrace.js +3 -4
  26. package/lib/feature-set.js +2 -1
  27. package/lib/hooks/encoding.js +1 -1
  28. package/lib/hooks/frameworks/base.js +8 -2
  29. package/lib/hooks/frameworks/http.js +23 -16
  30. package/lib/hooks/frameworks/http2.js +73 -0
  31. package/lib/hooks/frameworks/index.js +8 -3
  32. package/lib/hooks/http.js +112 -128
  33. package/lib/hooks/patcher.js +10 -12
  34. package/lib/hooks/require.js +16 -22
  35. package/lib/instrumentation.js +0 -3
  36. package/lib/protect/analysis/aho-corasick.js +13 -30
  37. package/lib/protect/rules/cmd-injection-command-backdoors/backdoor-detector.js +3 -3
  38. package/lib/protect/rules/signatures/reflected-xss/helpers/function-call.js +1 -1
  39. package/lib/protect/rules/xss/helpers/function-call.js +1 -1
  40. package/lib/util/clean-stack.js +1 -1
  41. package/lib/util/clean-string/brackets.js +3 -3
  42. package/lib/util/clean-string/concatenations.js +1 -1
  43. package/lib/util/clean-string/util.js +1 -2
  44. package/lib/util/ip-analyzer.js +1 -1
  45. package/lib/util/some.js +27 -0
  46. package/lib/util/xml-analyzer/external-entity-finder.js +1 -1
  47. package/package.json +14 -15
  48. package/lib/hooks/frameworks/https.js +0 -42
  49. package/node_modules/bindings/LICENSE.md +0 -22
  50. package/node_modules/bindings/README.md +0 -98
  51. package/node_modules/bindings/bindings.js +0 -221
  52. package/node_modules/bindings/package.json +0 -32
  53. package/node_modules/file-uri-to-path/.npmignore +0 -1
  54. package/node_modules/file-uri-to-path/.travis.yml +0 -30
  55. package/node_modules/file-uri-to-path/History.md +0 -21
  56. package/node_modules/file-uri-to-path/LICENSE +0 -20
  57. package/node_modules/file-uri-to-path/README.md +0 -74
  58. package/node_modules/file-uri-to-path/index.d.ts +0 -2
  59. package/node_modules/file-uri-to-path/index.js +0 -66
  60. package/node_modules/file-uri-to-path/package.json +0 -36
  61. package/node_modules/file-uri-to-path/test/test.js +0 -24
  62. package/node_modules/file-uri-to-path/test/tests.json +0 -13
  63. package/node_modules/glossy/LICENSE +0 -19
  64. package/node_modules/glossy/README.md +0 -129
  65. package/node_modules/glossy/index.js +0 -12
  66. package/node_modules/glossy/lib/glossy/parse.js +0 -520
  67. package/node_modules/glossy/lib/glossy/produce.js +0 -459
  68. package/node_modules/glossy/package.json +0 -47
  69. package/node_modules/glossy/test/decide.js +0 -7
  70. package/node_modules/glossy/test/decode_pri.js +0 -24
  71. package/node_modules/glossy/test/parse_3164.js +0 -104
  72. package/node_modules/glossy/test/parse_5424.js +0 -106
  73. package/node_modules/glossy/test/parse_5848.js +0 -40
  74. package/node_modules/glossy/test/parse_8601.js +0 -14
  75. package/node_modules/glossy/test/parse_rfc3339.js +0 -9
  76. package/node_modules/glossy/test/produce.js +0 -162
  77. package/node_modules/glossy/test/runner.js +0 -40
  78. package/node_modules/glossy/test/structure_data.js +0 -24
  79. package/node_modules/nan/CHANGELOG.md +0 -537
  80. package/node_modules/nan/LICENSE.md +0 -13
  81. package/node_modules/nan/README.md +0 -455
  82. package/node_modules/nan/doc/asyncworker.md +0 -146
  83. package/node_modules/nan/doc/buffers.md +0 -54
  84. package/node_modules/nan/doc/callback.md +0 -76
  85. package/node_modules/nan/doc/converters.md +0 -41
  86. package/node_modules/nan/doc/errors.md +0 -226
  87. package/node_modules/nan/doc/json.md +0 -62
  88. package/node_modules/nan/doc/maybe_types.md +0 -583
  89. package/node_modules/nan/doc/methods.md +0 -664
  90. package/node_modules/nan/doc/new.md +0 -147
  91. package/node_modules/nan/doc/node_misc.md +0 -123
  92. package/node_modules/nan/doc/object_wrappers.md +0 -263
  93. package/node_modules/nan/doc/persistent.md +0 -296
  94. package/node_modules/nan/doc/scopes.md +0 -73
  95. package/node_modules/nan/doc/script.md +0 -38
  96. package/node_modules/nan/doc/string_bytes.md +0 -62
  97. package/node_modules/nan/doc/v8_internals.md +0 -199
  98. package/node_modules/nan/doc/v8_misc.md +0 -85
  99. package/node_modules/nan/include_dirs.js +0 -1
  100. package/node_modules/nan/nan.h +0 -2898
  101. package/node_modules/nan/nan_callbacks.h +0 -88
  102. package/node_modules/nan/nan_callbacks_12_inl.h +0 -514
  103. package/node_modules/nan/nan_callbacks_pre_12_inl.h +0 -520
  104. package/node_modules/nan/nan_converters.h +0 -72
  105. package/node_modules/nan/nan_converters_43_inl.h +0 -68
  106. package/node_modules/nan/nan_converters_pre_43_inl.h +0 -42
  107. package/node_modules/nan/nan_define_own_property_helper.h +0 -29
  108. package/node_modules/nan/nan_implementation_12_inl.h +0 -430
  109. package/node_modules/nan/nan_implementation_pre_12_inl.h +0 -263
  110. package/node_modules/nan/nan_json.h +0 -166
  111. package/node_modules/nan/nan_maybe_43_inl.h +0 -356
  112. package/node_modules/nan/nan_maybe_pre_43_inl.h +0 -268
  113. package/node_modules/nan/nan_new.h +0 -340
  114. package/node_modules/nan/nan_object_wrap.h +0 -156
  115. package/node_modules/nan/nan_persistent_12_inl.h +0 -132
  116. package/node_modules/nan/nan_persistent_pre_12_inl.h +0 -242
  117. package/node_modules/nan/nan_private.h +0 -73
  118. package/node_modules/nan/nan_string_bytes.h +0 -305
  119. package/node_modules/nan/nan_typedarray_contents.h +0 -96
  120. package/node_modules/nan/nan_weak.h +0 -437
  121. package/node_modules/nan/package.json +0 -41
  122. package/node_modules/nan/tools/1to2.js +0 -412
  123. package/node_modules/nan/tools/README.md +0 -14
  124. package/node_modules/nan/tools/package.json +0 -19
  125. package/node_modules/unix-dgram/LICENSE +0 -13
  126. package/node_modules/unix-dgram/README.md +0 -107
  127. package/node_modules/unix-dgram/binding.gyp +0 -20
  128. package/node_modules/unix-dgram/build/Makefile +0 -324
  129. package/node_modules/unix-dgram/build/Release/.deps/Release/obj.target/unix_dgram/src/unix_dgram.o.d +0 -58
  130. package/node_modules/unix-dgram/build/Release/.deps/Release/obj.target/unix_dgram.node.d +0 -1
  131. package/node_modules/unix-dgram/build/Release/.deps/Release/unix_dgram.node.d +0 -1
  132. package/node_modules/unix-dgram/build/Release/obj.target/unix_dgram/src/unix_dgram.o +0 -0
  133. package/node_modules/unix-dgram/build/Release/obj.target/unix_dgram.node +0 -0
  134. package/node_modules/unix-dgram/build/Release/unix_dgram.node +0 -0
  135. package/node_modules/unix-dgram/build/binding.Makefile +0 -6
  136. package/node_modules/unix-dgram/build/config.gypi +0 -213
  137. package/node_modules/unix-dgram/build/unix_dgram.target.mk +0 -159
  138. package/node_modules/unix-dgram/lib/unix_dgram.js +0 -168
  139. package/node_modules/unix-dgram/package.json +0 -36
  140. package/node_modules/unix-dgram/src/unix_dgram.cc +0 -404
  141. package/node_modules/unix-dgram/src/win_dummy.cc +0 -7
  142. package/node_modules/unix-dgram/test/test-connect-callback.js +0 -68
  143. package/node_modules/unix-dgram/test/test-connect.js +0 -53
  144. package/node_modules/unix-dgram/test/test-dgram-unix.js +0 -58
  145. package/node_modules/unix-dgram/test/test-send-error.js +0 -26
  146. package/node_modules/winston-syslog/.eslintrc +0 -7
  147. package/node_modules/winston-syslog/.travis.yml +0 -14
  148. package/node_modules/winston-syslog/CHANGELOG.md +0 -9
  149. package/node_modules/winston-syslog/LICENSE +0 -20
  150. package/node_modules/winston-syslog/README.md +0 -135
  151. package/node_modules/winston-syslog/lib/utils.js +0 -26
  152. package/node_modules/winston-syslog/lib/winston-syslog.js +0 -385
  153. package/node_modules/winston-syslog/package.json +0 -56
  154. package/node_modules/winston-syslog/test/format-test.js +0 -122
  155. package/node_modules/winston-syslog/test/syslog-test.js +0 -95
  156. package/node_modules/winston-syslog/test/unix-connect-test.js +0 -133
@@ -109,7 +109,7 @@ class Concatenations {
109
109
  }
110
110
 
111
111
  /**
112
- * Captures the next string concatenation occurrance
112
+ * Captures the next string concatenation occurrence
113
113
  * within the instance's string value.
114
114
  * @param {} info
115
115
  * @param {} str
@@ -27,9 +27,8 @@ function searchTimesF(times, target, str, startIdx) {
27
27
 
28
28
  const coll = [];
29
29
  let counter = -1;
30
- const stop = false;
31
30
 
32
- while (0 < times - ++counter || stop) {
31
+ while (0 < times - ++counter) {
33
32
  const fromIndex =
34
33
  coll[counter - 1] !== undefined ? coll[counter - 1] : startIdx;
35
34
  const idx = str.indexOf(target, fromIndex + 1);
@@ -66,7 +66,7 @@ const getReqAddresses = (req = {}) => {
66
66
  */
67
67
  const getForwardedFor = (req = {}) => {
68
68
  const header = req.headers && req.headers['x-forwarded-for'];
69
- return header ? header.split(/\s*,\s*/) : [];
69
+ return header ? header.split(',').map((x) => x.trim()) : [];
70
70
  };
71
71
 
72
72
  /**
@@ -0,0 +1,27 @@
1
+ /**
2
+ Copyright: 2021 Contrast Security, Inc
3
+ Contact: support@contrastsecurity.com
4
+ License: Commercial
5
+
6
+ NOTICE: This Software and the patented inventions embodied within may only be
7
+ used as part of Contrast Security’s commercial offerings. Even though it is
8
+ made available through public repositories, use of this Software is subject to
9
+ the applicable End User Licensing Agreement found at
10
+ https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
11
+ between Contrast Security and the End User. The Software may not be reverse
12
+ engineered, modified, repackaged, sold, redistributed or otherwise used in a
13
+ way not consistent with the End User License Agreement.
14
+ */
15
+ function some(array, predicate) {
16
+ let index = -1;
17
+ const length = array == null ? 0 : array.length;
18
+
19
+ while (++index < length) {
20
+ if (predicate(array[index], index, array)) {
21
+ return true;
22
+ }
23
+ }
24
+ return false;
25
+ }
26
+
27
+ module.exports = some;
@@ -38,7 +38,7 @@ const UP_DIR_LINUX = '../';
38
38
  const UP_DIR_WIN = '..\\';
39
39
  const ENTITY_TYPES = { SYSTEM: 'SYSTEM', PUBLIC: 'PUBLIC' };
40
40
 
41
- const EXTERNAL_RX = /<!ENTITY\s+[a-zA-Z0-f]+\s+(?:SYSTEM|PUBLIC)\s+(?:.*?)>/g;
41
+ const EXTERNAL_RX = /<!ENTITY\s+[a-zA-Z0-f]+\s+(?:SYSTEM|PUBLIC)\s+"(.*?)"\s*>/g;
42
42
  // <!ENTITY name SYSTEM "URI">
43
43
  const SYSTEM_ID_REGEX = /<!ENTITY\s+([a-zA-Z0-9]+)\s+SYSTEM\s+"(.*?)"\s*>/;
44
44
  // <!ENTITY name PUBLIC "public_ID" "URI">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/agent",
3
- "version": "4.4.1",
3
+ "version": "4.6.0",
4
4
  "description": "Node.js security instrumentation by Contrast Security",
5
5
  "keywords": [
6
6
  "security",
@@ -38,7 +38,8 @@
38
38
  "extract-licenses": "node scripts/extract-licenses",
39
39
  "fix": "eslint . --fix",
40
40
  "prepare": "husky install || exit 0",
41
- "preversion": "npm run test:gh-ci"
41
+ "preversion": "npm run test:gh-ci",
42
+ "initsecrets": "scripts/detect-secrets.sh"
42
43
  },
43
44
  "lint-staged": {
44
45
  "*.js": "eslint --fix",
@@ -74,11 +75,10 @@
74
75
  "@contrast/fn-inspect": "^2.4.2",
75
76
  "@contrast/heapdump": "^1.1.0",
76
77
  "@contrast/protobuf-api": "^3.2.0",
77
- "@contrast/require-hook": "^2.0.5",
78
+ "@contrast/require-hook": "^2.0.6",
78
79
  "@contrast/synchronous-source-maps": "^1.1.0",
79
80
  "amqp-connection-manager": "^3.2.2",
80
81
  "amqplib": "^0.8.0",
81
- "base64url": "^3.0.1",
82
82
  "big-integer": "^1.6.36",
83
83
  "bluebird": "^3.5.3",
84
84
  "builtin-modules": "^3.2.0",
@@ -94,25 +94,22 @@
94
94
  "jspack": "0.0.4",
95
95
  "lodash": "^4.17.21",
96
96
  "make-dir": "^3.1.0",
97
- "moment": "^2.21.0",
98
97
  "multi-stage-sourcemap": "^0.3.1",
99
98
  "on-finished": "^2.3.0",
100
99
  "parseurl": "^1.3.3",
101
100
  "prom-client": "^12.0.0",
102
101
  "recursive-readdir": "^2.2.2",
103
- "request": "^2.88.0",
104
102
  "semver": "^7.3.2",
105
- "source-map": "^0.7.3",
106
103
  "winston": "^3.1.0",
107
104
  "winston-daily-rotate-file": "^3.5.1",
108
- "winston-syslog": "2.1.0",
109
105
  "yaml": "^1.10.0"
110
106
  },
111
107
  "devDependencies": {
108
+ "@aws-sdk/client-dynamodb": "^3.39.0",
112
109
  "@bmacnaughton/string-generator": "^1.0.0",
113
110
  "@contrast/eslint-config": "^2.0.1",
114
111
  "@contrast/fake-module": "file:test/mock/contrast-fake",
115
- "@contrast/screener-service": "^1.12.4",
112
+ "@contrast/screener-service": "^1.12.5",
116
113
  "@hapi/boom": "file:test/mock/boom",
117
114
  "@hapi/hapi": "file:test/mock/hapi",
118
115
  "@ls-lint/ls-lint": "^1.8.1",
@@ -129,8 +126,10 @@
129
126
  "config": "^3.3.3",
130
127
  "csv-writer": "^1.2.0",
131
128
  "deasync": "^0.1.20",
129
+ "dustjs-linkedin": "^3.0.0",
130
+ "ejs": "^3.1.6",
132
131
  "escape-html": "^1.0.3",
133
- "eslint": "^5.16.0",
132
+ "eslint": "^8.2.0",
134
133
  "eslint-config-prettier": "^6.11.0",
135
134
  "eslint-plugin-mocha": "^7.0.1",
136
135
  "eslint-plugin-node": "^11.1.0",
@@ -146,11 +145,11 @@
146
145
  "jsdoc": "^3.6.7",
147
146
  "libxmljs": "file:test/mock/libxmljs",
148
147
  "libxmljs2": "file:test/mock/libxmljs2",
149
- "lint-staged": "^11.0.0",
148
+ "lint-staged": "^12.0.2",
150
149
  "madge": "^4.0.1",
151
150
  "marsdb": "file:test/mock/marsdb",
152
- "mocha": "^8.2.0",
153
- "mochawesome": "^6.2.2",
151
+ "mocha": "^9.1.3",
152
+ "mochawesome": "^7.0.1",
154
153
  "mongodb": "file:test/mock/mongodb",
155
154
  "mongodb-npm": "npm:mongodb@^3.6.5",
156
155
  "mustache": "^3.0.1",
@@ -159,7 +158,7 @@
159
158
  "node-fetch": "^2.6.1",
160
159
  "node-serialize": "file:test/mock/node-serialize",
161
160
  "npm-license-crawler": "^0.2.1",
162
- "nyc": "^15.0.0",
161
+ "nyc": "^15.1.0",
163
162
  "pg": "file:test/mock/pg",
164
163
  "pino": "^6.7.0",
165
164
  "prettier": "^1.19.1",
@@ -175,7 +174,7 @@
175
174
  "triple-beam": "^1.3.0",
176
175
  "typeorm": "file:test/mock/typeorm",
177
176
  "uuid": "^8.3.1",
178
- "validator": "^13.5.2",
177
+ "validator": "^13.7.0",
179
178
  "xpath": "file:test/mock/xpath"
180
179
  },
181
180
  "main": "bootstrap.js",
@@ -1,42 +0,0 @@
1
- /**
2
- Copyright: 2021 Contrast Security, Inc
3
- Contact: support@contrastsecurity.com
4
- License: Commercial
5
-
6
- NOTICE: This Software and the patented inventions embodied within may only be
7
- used as part of Contrast Security’s commercial offerings. Even though it is
8
- made available through public repositories, use of this Software is subject to
9
- the applicable End User Licensing Agreement found at
10
- https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
11
- between Contrast Security and the End User. The Software may not be reverse
12
- engineered, modified, repackaged, sold, redistributed or otherwise used in a
13
- way not consistent with the End User License Agreement.
14
- */
15
- 'use strict';
16
-
17
- const emitter = require('../../agent-emitter');
18
- const { HTTP_EVENTS } = require('../../constants');
19
- const HttpFramework = require('./http');
20
-
21
- const id = 'https';
22
-
23
- class HttpsFramework extends HttpFramework {
24
- constructor(agent) {
25
- super(agent, id);
26
- }
27
-
28
- /**
29
- * Override for <code>HttpSource.prototype.handleServerCreate</code>.
30
- * We override in order to emit the event with the proper callback argument -
31
- * HTTPS servers take an `options` object as the first argument. We want the
32
- * second callback argument.
33
- * @param {*[]} args The arguments passed to the Server constructor
34
- * @param {Server} server
35
- */
36
- handleServerCreate(args, server) {
37
- const callback = args[1];
38
- emitter.emit(HTTP_EVENTS.SERVER_CREATE, callback, server);
39
- }
40
- }
41
-
42
- module.exports = HttpsFramework;
@@ -1,22 +0,0 @@
1
- (The MIT License)
2
-
3
- Copyright (c) 2012 Nathan Rajlich &lt;nathan@tootallnate.net&gt;
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- 'Software'), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,98 +0,0 @@
1
- node-bindings
2
- =============
3
- ### Helper module for loading your native module's `.node` file
4
-
5
- This is a helper module for authors of Node.js native addon modules.
6
- It is basically the "swiss army knife" of `require()`ing your native module's
7
- `.node` file.
8
-
9
- Throughout the course of Node's native addon history, addons have ended up being
10
- compiled in a variety of different places, depending on which build tool and which
11
- version of node was used. To make matters worse, now the `gyp` build tool can
12
- produce either a __Release__ or __Debug__ build, each being built into different
13
- locations.
14
-
15
- This module checks _all_ the possible locations that a native addon would be built
16
- at, and returns the first one that loads successfully.
17
-
18
-
19
- Installation
20
- ------------
21
-
22
- Install with `npm`:
23
-
24
- ``` bash
25
- $ npm install --save bindings
26
- ```
27
-
28
- Or add it to the `"dependencies"` section of your `package.json` file.
29
-
30
-
31
- Example
32
- -------
33
-
34
- `require()`ing the proper bindings file for the current node version, platform
35
- and architecture is as simple as:
36
-
37
- ``` js
38
- var bindings = require('bindings')('binding.node')
39
-
40
- // Use your bindings defined in your C files
41
- bindings.your_c_function()
42
- ```
43
-
44
-
45
- Nice Error Output
46
- -----------------
47
-
48
- When the `.node` file could not be loaded, `node-bindings` throws an Error with
49
- a nice error message telling you exactly what was tried. You can also check the
50
- `err.tries` Array property.
51
-
52
- ```
53
- Error: Could not load the bindings file. Tried:
54
- → /Users/nrajlich/ref/build/binding.node
55
- → /Users/nrajlich/ref/build/Debug/binding.node
56
- → /Users/nrajlich/ref/build/Release/binding.node
57
- → /Users/nrajlich/ref/out/Debug/binding.node
58
- → /Users/nrajlich/ref/Debug/binding.node
59
- → /Users/nrajlich/ref/out/Release/binding.node
60
- → /Users/nrajlich/ref/Release/binding.node
61
- → /Users/nrajlich/ref/build/default/binding.node
62
- → /Users/nrajlich/ref/compiled/0.8.2/darwin/x64/binding.node
63
- at bindings (/Users/nrajlich/ref/node_modules/bindings/bindings.js:84:13)
64
- at Object.<anonymous> (/Users/nrajlich/ref/lib/ref.js:5:47)
65
- at Module._compile (module.js:449:26)
66
- at Object.Module._extensions..js (module.js:467:10)
67
- at Module.load (module.js:356:32)
68
- at Function.Module._load (module.js:312:12)
69
- ...
70
- ```
71
-
72
- The searching for the `.node` file will originate from the first directory in which has a `package.json` file is found.
73
-
74
- License
75
- -------
76
-
77
- (The MIT License)
78
-
79
- Copyright (c) 2012 Nathan Rajlich &lt;nathan@tootallnate.net&gt;
80
-
81
- Permission is hereby granted, free of charge, to any person obtaining
82
- a copy of this software and associated documentation files (the
83
- 'Software'), to deal in the Software without restriction, including
84
- without limitation the rights to use, copy, modify, merge, publish,
85
- distribute, sublicense, and/or sell copies of the Software, and to
86
- permit persons to whom the Software is furnished to do so, subject to
87
- the following conditions:
88
-
89
- The above copyright notice and this permission notice shall be
90
- included in all copies or substantial portions of the Software.
91
-
92
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
93
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
94
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
95
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
96
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
97
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
98
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,221 +0,0 @@
1
- /**
2
- * Module dependencies.
3
- */
4
-
5
- var fs = require('fs'),
6
- path = require('path'),
7
- fileURLToPath = require('file-uri-to-path'),
8
- join = path.join,
9
- dirname = path.dirname,
10
- exists =
11
- (fs.accessSync &&
12
- function(path) {
13
- try {
14
- fs.accessSync(path);
15
- } catch (e) {
16
- return false;
17
- }
18
- return true;
19
- }) ||
20
- fs.existsSync ||
21
- path.existsSync,
22
- defaults = {
23
- arrow: process.env.NODE_BINDINGS_ARROW || ' → ',
24
- compiled: process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled',
25
- platform: process.platform,
26
- arch: process.arch,
27
- nodePreGyp:
28
- 'node-v' +
29
- process.versions.modules +
30
- '-' +
31
- process.platform +
32
- '-' +
33
- process.arch,
34
- version: process.versions.node,
35
- bindings: 'bindings.node',
36
- try: [
37
- // node-gyp's linked version in the "build" dir
38
- ['module_root', 'build', 'bindings'],
39
- // node-waf and gyp_addon (a.k.a node-gyp)
40
- ['module_root', 'build', 'Debug', 'bindings'],
41
- ['module_root', 'build', 'Release', 'bindings'],
42
- // Debug files, for development (legacy behavior, remove for node v0.9)
43
- ['module_root', 'out', 'Debug', 'bindings'],
44
- ['module_root', 'Debug', 'bindings'],
45
- // Release files, but manually compiled (legacy behavior, remove for node v0.9)
46
- ['module_root', 'out', 'Release', 'bindings'],
47
- ['module_root', 'Release', 'bindings'],
48
- // Legacy from node-waf, node <= 0.4.x
49
- ['module_root', 'build', 'default', 'bindings'],
50
- // Production "Release" buildtype binary (meh...)
51
- ['module_root', 'compiled', 'version', 'platform', 'arch', 'bindings'],
52
- // node-qbs builds
53
- ['module_root', 'addon-build', 'release', 'install-root', 'bindings'],
54
- ['module_root', 'addon-build', 'debug', 'install-root', 'bindings'],
55
- ['module_root', 'addon-build', 'default', 'install-root', 'bindings'],
56
- // node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
57
- ['module_root', 'lib', 'binding', 'nodePreGyp', 'bindings']
58
- ]
59
- };
60
-
61
- /**
62
- * The main `bindings()` function loads the compiled bindings for a given module.
63
- * It uses V8's Error API to determine the parent filename that this function is
64
- * being invoked from, which is then used to find the root directory.
65
- */
66
-
67
- function bindings(opts) {
68
- // Argument surgery
69
- if (typeof opts == 'string') {
70
- opts = { bindings: opts };
71
- } else if (!opts) {
72
- opts = {};
73
- }
74
-
75
- // maps `defaults` onto `opts` object
76
- Object.keys(defaults).map(function(i) {
77
- if (!(i in opts)) opts[i] = defaults[i];
78
- });
79
-
80
- // Get the module root
81
- if (!opts.module_root) {
82
- opts.module_root = exports.getRoot(exports.getFileName());
83
- }
84
-
85
- // Ensure the given bindings name ends with .node
86
- if (path.extname(opts.bindings) != '.node') {
87
- opts.bindings += '.node';
88
- }
89
-
90
- // https://github.com/webpack/webpack/issues/4175#issuecomment-342931035
91
- var requireFunc =
92
- typeof __webpack_require__ === 'function'
93
- ? __non_webpack_require__
94
- : require;
95
-
96
- var tries = [],
97
- i = 0,
98
- l = opts.try.length,
99
- n,
100
- b,
101
- err;
102
-
103
- for (; i < l; i++) {
104
- n = join.apply(
105
- null,
106
- opts.try[i].map(function(p) {
107
- return opts[p] || p;
108
- })
109
- );
110
- tries.push(n);
111
- try {
112
- b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
113
- if (!opts.path) {
114
- b.path = n;
115
- }
116
- return b;
117
- } catch (e) {
118
- if (e.code !== 'MODULE_NOT_FOUND' &&
119
- e.code !== 'QUALIFIED_PATH_RESOLUTION_FAILED' &&
120
- !/not find/i.test(e.message)) {
121
- throw e;
122
- }
123
- }
124
- }
125
-
126
- err = new Error(
127
- 'Could not locate the bindings file. Tried:\n' +
128
- tries
129
- .map(function(a) {
130
- return opts.arrow + a;
131
- })
132
- .join('\n')
133
- );
134
- err.tries = tries;
135
- throw err;
136
- }
137
- module.exports = exports = bindings;
138
-
139
- /**
140
- * Gets the filename of the JavaScript file that invokes this function.
141
- * Used to help find the root directory of a module.
142
- * Optionally accepts an filename argument to skip when searching for the invoking filename
143
- */
144
-
145
- exports.getFileName = function getFileName(calling_file) {
146
- var origPST = Error.prepareStackTrace,
147
- origSTL = Error.stackTraceLimit,
148
- dummy = {},
149
- fileName;
150
-
151
- Error.stackTraceLimit = 10;
152
-
153
- Error.prepareStackTrace = function(e, st) {
154
- for (var i = 0, l = st.length; i < l; i++) {
155
- fileName = st[i].getFileName();
156
- if (fileName !== __filename) {
157
- if (calling_file) {
158
- if (fileName !== calling_file) {
159
- return;
160
- }
161
- } else {
162
- return;
163
- }
164
- }
165
- }
166
- };
167
-
168
- // run the 'prepareStackTrace' function above
169
- Error.captureStackTrace(dummy);
170
- dummy.stack;
171
-
172
- // cleanup
173
- Error.prepareStackTrace = origPST;
174
- Error.stackTraceLimit = origSTL;
175
-
176
- // handle filename that starts with "file://"
177
- var fileSchema = 'file://';
178
- if (fileName.indexOf(fileSchema) === 0) {
179
- fileName = fileURLToPath(fileName);
180
- }
181
-
182
- return fileName;
183
- };
184
-
185
- /**
186
- * Gets the root directory of a module, given an arbitrary filename
187
- * somewhere in the module tree. The "root directory" is the directory
188
- * containing the `package.json` file.
189
- *
190
- * In: /home/nate/node-native-module/lib/index.js
191
- * Out: /home/nate/node-native-module
192
- */
193
-
194
- exports.getRoot = function getRoot(file) {
195
- var dir = dirname(file),
196
- prev;
197
- while (true) {
198
- if (dir === '.') {
199
- // Avoids an infinite loop in rare cases, like the REPL
200
- dir = process.cwd();
201
- }
202
- if (
203
- exists(join(dir, 'package.json')) ||
204
- exists(join(dir, 'node_modules'))
205
- ) {
206
- // Found the 'package.json' file or 'node_modules' dir; we're done
207
- return dir;
208
- }
209
- if (prev === dir) {
210
- // Got to the top
211
- throw new Error(
212
- 'Could not find module root given file: "' +
213
- file +
214
- '". Do you have a `package.json` file? '
215
- );
216
- }
217
- // Try the parent dir next
218
- prev = dir;
219
- dir = join(dir, '..');
220
- }
221
- };
@@ -1,32 +0,0 @@
1
- {
2
- "name": "bindings",
3
- "description": "Helper module for loading your native module's .node file",
4
- "keywords": [
5
- "native",
6
- "addon",
7
- "bindings",
8
- "gyp",
9
- "waf",
10
- "c",
11
- "c++"
12
- ],
13
- "version": "1.5.0",
14
- "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)",
15
- "repository": {
16
- "type": "git",
17
- "url": "git://github.com/TooTallNate/node-bindings.git"
18
- },
19
- "main": "./bindings.js",
20
- "bugs": {
21
- "url": "https://github.com/TooTallNate/node-bindings/issues"
22
- },
23
- "homepage": "https://github.com/TooTallNate/node-bindings",
24
- "license": "MIT",
25
- "dependencies": {
26
- "file-uri-to-path": "1.0.0"
27
- }
28
-
29
- ,"_resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz"
30
- ,"_integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ=="
31
- ,"_from": "bindings@1.5.0"
32
- }
@@ -1 +0,0 @@
1
- /node_modules
@@ -1,30 +0,0 @@
1
- sudo: false
2
-
3
- language: node_js
4
-
5
- node_js:
6
- - "0.8"
7
- - "0.10"
8
- - "0.12"
9
- - "1"
10
- - "2"
11
- - "3"
12
- - "4"
13
- - "5"
14
- - "6"
15
- - "7"
16
- - "8"
17
-
18
- install:
19
- - PATH="`npm bin`:`npm bin -g`:$PATH"
20
- # Node 0.8 comes with a too obsolete npm
21
- - if [[ "`node --version`" =~ ^v0\.8\. ]]; then npm install -g npm@1.4.28 ; fi
22
- # Install dependencies and build
23
- - npm install
24
-
25
- script:
26
- # Output useful info for debugging
27
- - node --version
28
- - npm --version
29
- # Run tests
30
- - npm test
@@ -1,21 +0,0 @@
1
-
2
- 1.0.0 / 2017-07-06
3
- ==================
4
-
5
- * update "mocha" to v3
6
- * fixed unicode URI decoding (#6)
7
- * add typings for Typescript
8
- * README: use SVG Travis-CI badge
9
- * add LICENSE file (MIT)
10
- * add .travis.yml file (testing Node.js 0.8 through 8 currently)
11
- * add README.md file
12
-
13
- 0.0.2 / 2014-01-27
14
- ==================
15
-
16
- * index: invert the path separators on Windows
17
-
18
- 0.0.1 / 2014-01-27
19
- ==================
20
-
21
- * initial commit
@@ -1,20 +0,0 @@
1
- Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- 'Software'), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.