@contrast/agent 4.5.2 → 4.8.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.
- package/LICENSE +1 -1
- package/agent-loader.js +1 -1
- package/bin/VERSION +1 -1
- package/bin/linux/contrast-service +0 -0
- package/bin/mac/contrast-service +0 -0
- package/bin/windows/contrast-service.exe +0 -0
- package/bootstrap.js +1 -1
- package/cli-rewriter.js +1 -1
- package/cli.js +1 -1
- package/esm.mjs +1 -1
- package/lib/agent-emitter.js +1 -1
- package/lib/agent.js +1 -1
- package/lib/app-info.js +1 -1
- package/lib/assess/deadzones/index.js +1 -1
- package/lib/assess/deadzones/rewrite.js +1 -1
- package/lib/assess/express/index.js +1 -1
- package/lib/assess/express/route-coverage.js +1 -1
- package/lib/assess/express/sinks/index.js +1 -1
- package/lib/assess/express/sinks/xss.js +1 -1
- package/lib/assess/express/sources.js +1 -1
- package/lib/assess/fastify/index.js +1 -1
- package/lib/assess/fastify/route-coverage.js +1 -1
- package/lib/assess/fastify/sinks/index.js +1 -1
- package/lib/assess/fastify/sinks/response-scanning.js +1 -1
- package/lib/assess/fastify/sinks/unvalidated-redirect.js +1 -1
- package/lib/assess/fastify/sinks/xss.js +1 -1
- package/lib/assess/fastify/sources.js +1 -1
- package/lib/assess/hapi/index.js +1 -1
- package/lib/assess/hapi/route-coverage.js +1 -1
- package/lib/assess/hapi/sinks/index.js +1 -1
- package/lib/assess/hapi/sinks/response-scanning.js +1 -1
- package/lib/assess/hapi/sinks/session.js +1 -1
- package/lib/assess/hapi/sinks/unvalidated-redirect.js +1 -1
- package/lib/assess/hapi/sinks/xss.js +1 -1
- package/lib/assess/hapi/sources.js +1 -1
- package/lib/assess/index.js +1 -1
- package/lib/assess/koa/index.js +1 -1
- package/lib/assess/koa/route-coverage.js +1 -1
- package/lib/assess/koa/sinks/index.js +1 -1
- package/lib/assess/koa/sinks/response-scanning.js +1 -1
- package/lib/assess/koa/sinks/unvalidated-redirect.js +1 -1
- package/lib/assess/koa/sinks/xss.js +1 -1
- package/lib/assess/koa/sources.js +1 -1
- package/lib/assess/loopback4/index.js +1 -1
- package/lib/assess/loopback4/route-coverage.js +1 -1
- package/lib/assess/loopback4/sinks/index.js +1 -1
- package/lib/assess/loopback4/sinks/response-scanning.js +1 -1
- package/lib/assess/loopback4/sinks/xss.js +1 -1
- package/lib/assess/loopback4/sources.js +1 -1
- package/lib/assess/membrane/debraner.js +1 -1
- package/lib/assess/membrane/deserialization-membrane.js +5 -6
- package/lib/assess/membrane/index.js +1 -1
- package/lib/assess/membrane/source-membrane.js +17 -34
- package/lib/assess/models/base-event.js +1 -1
- package/lib/assess/models/call-context.js +2 -2
- package/lib/assess/models/index.js +1 -1
- package/lib/assess/models/propagation-event.js +1 -1
- package/lib/assess/models/signature.js +1 -1
- package/lib/assess/models/sink-event.js +1 -1
- package/lib/assess/models/source-event.js +1 -1
- package/lib/assess/models/tag-range/index.js +1 -1
- package/lib/assess/models/tag-range/relationships.js +1 -1
- package/lib/assess/models/tag-range/util.js +1 -1
- package/lib/assess/policy/index.js +1 -1
- package/lib/assess/policy/init.js +1 -1
- package/lib/assess/policy/propagators.json +19 -21
- package/lib/assess/policy/rules.json +7 -2
- package/lib/assess/policy/signatures.json +42 -6
- package/lib/assess/policy/util.js +3 -2
- package/lib/assess/propagators/JSON/parse.js +2 -2
- package/lib/assess/propagators/JSON/stringify.js +4 -4
- package/lib/assess/propagators/ajv/conditionals.js +1 -1
- package/lib/assess/propagators/ajv/evaluator-shim.js +1 -1
- package/lib/assess/propagators/ajv/index.js +1 -1
- package/lib/assess/propagators/ajv/json-schema-type-evaluators.js +1 -1
- package/lib/assess/propagators/ajv/object-walk.js +1 -1
- package/lib/assess/propagators/ajv/refs.js +1 -1
- package/lib/assess/propagators/ajv/schema-context.js +1 -1
- package/lib/assess/propagators/array-prototype-join.js +8 -9
- package/lib/assess/propagators/common.js +8 -6
- package/lib/assess/propagators/dustjs/escape-html.js +22 -0
- package/lib/assess/propagators/dustjs/escape-js.js +22 -0
- package/lib/assess/propagators/ejs-template-generate-source.js +1 -1
- package/lib/assess/propagators/encode-uri/encode-uri-component.js +22 -0
- package/lib/assess/propagators/encode-uri/encode-uri.js +22 -0
- package/lib/assess/propagators/handlebars-compile.js +1 -1
- package/lib/assess/propagators/handlebars-escape-expresssion.js +2 -2
- package/lib/assess/propagators/index.js +1 -3
- package/lib/assess/propagators/joi/boolean.js +2 -2
- package/lib/assess/propagators/joi/expression.js +2 -2
- package/lib/assess/propagators/joi/index.js +1 -1
- package/lib/assess/propagators/joi/number.js +2 -2
- package/lib/assess/propagators/joi/string-base.js +2 -2
- package/lib/assess/propagators/joi/string-schema.js +13 -14
- package/lib/assess/propagators/joi/values.js +38 -23
- package/lib/assess/propagators/manager.js +13 -11
- package/lib/assess/propagators/mongoose/helpers.js +20 -0
- package/lib/assess/propagators/mongoose/index.js +18 -0
- package/lib/assess/propagators/mongoose/map.js +74 -0
- package/lib/assess/propagators/mongoose/string.js +104 -0
- package/lib/assess/propagators/mustache/escape.js +22 -0
- package/lib/assess/propagators/number.js +54 -0
- package/lib/assess/propagators/object.js +7 -8
- package/lib/assess/propagators/path/basename.js +15 -14
- package/lib/assess/propagators/path/common.js +2 -2
- package/lib/assess/propagators/path/dirname.js +15 -14
- package/lib/assess/propagators/path/extname.js +15 -14
- package/lib/assess/propagators/path/format.js +1 -1
- package/lib/assess/propagators/path/join.js +1 -1
- package/lib/assess/propagators/path/normalize.js +1 -1
- package/lib/assess/propagators/path/parse.js +2 -2
- package/lib/assess/propagators/path/relative.js +8 -6
- package/lib/assess/propagators/path/resolve.js +1 -1
- package/lib/assess/propagators/path/to-namespaced-path.js +1 -1
- package/lib/assess/propagators/pug-compile.js +1 -1
- package/lib/assess/propagators/querystring/escape.js +21 -19
- package/lib/assess/propagators/querystring/parse.js +8 -6
- package/lib/assess/propagators/querystring/stringify.js +26 -25
- package/lib/assess/propagators/querystring/unescape.js +21 -19
- package/lib/assess/propagators/querystring/utils.js +1 -1
- package/lib/assess/propagators/sequelize/sql-string-escape.js +2 -2
- package/lib/assess/propagators/sequelize/sql-string-format-named-parameters.js +2 -2
- package/lib/assess/propagators/sequelize/sql-string-format.js +4 -4
- package/lib/assess/propagators/sequelize/utils.js +3 -3
- package/lib/assess/propagators/string-prototype-replace.js +31 -29
- package/lib/assess/propagators/string-prototype-split.js +37 -37
- package/lib/assess/propagators/string-prototype-trim.js +16 -18
- package/lib/assess/propagators/string.js +13 -17
- package/lib/assess/propagators/template-escape.js +87 -0
- package/lib/assess/propagators/templates.js +11 -12
- package/lib/assess/propagators/url/url-prototype-parse.js +6 -7
- package/lib/assess/propagators/url/url-url.js +52 -44
- package/lib/assess/propagators/url/utils.js +1 -1
- package/lib/assess/propagators/util/format.js +2 -2
- package/lib/assess/propagators/utils.js +1 -1
- package/lib/assess/propagators/v8/init-hooks.js +4 -4
- package/lib/assess/propagators/validator/init-hooks.js +23 -23
- package/lib/assess/propagators/validator/validator-methods.js +1 -2
- package/lib/assess/response-scanning/app-activity.js +1 -1
- package/lib/assess/response-scanning/autocomplete-missing.js +1 -1
- package/lib/assess/response-scanning/cache-controls-missing.js +1 -1
- package/lib/assess/response-scanning/clickjacking-control-missing.js +1 -1
- package/lib/assess/response-scanning/common.js +1 -1
- package/lib/assess/response-scanning/cookies/common.js +1 -1
- package/lib/assess/response-scanning/cookies/events.js +1 -1
- package/lib/assess/response-scanning/cookies/httponly.js +1 -1
- package/lib/assess/response-scanning/cookies/secure-flag-missing.js +1 -1
- package/lib/assess/response-scanning/headers/csp-header-insecure.js +1 -1
- package/lib/assess/response-scanning/headers/csp-header-missing.js +1 -1
- package/lib/assess/response-scanning/headers/csp-utils.js +1 -1
- package/lib/assess/response-scanning/headers/hsts-header-missing.js +1 -1
- package/lib/assess/response-scanning/headers/powered-by.js +1 -1
- package/lib/assess/response-scanning/headers/xcontenttype-header-missing.js +1 -1
- package/lib/assess/response-scanning/headers/xxssprotection-header-disabled.js +1 -1
- package/lib/assess/response-scanning/parameter-pollution.js +1 -1
- package/lib/assess/response-scanning/parseable-response-emitter.js +1 -1
- package/lib/assess/restify/index.js +1 -1
- package/lib/assess/restify/route-coverage.js +1 -1
- package/lib/assess/restify/session.js +1 -1
- package/lib/assess/restify/sinks/index.js +1 -1
- package/lib/assess/restify/sinks/response-scanning.js +1 -1
- package/lib/assess/restify/sinks/unvalidated-redirect.js +1 -1
- package/lib/assess/restify/sinks/xss.js +1 -1
- package/lib/assess/restify/sources.js +1 -1
- package/lib/assess/sinks/common.js +11 -6
- package/lib/assess/sinks/dustjs-linkedin-xss.js +131 -0
- package/lib/assess/sinks/dynamo.js +1 -1
- package/lib/assess/sinks/hapi-16-xss.js +1 -1
- package/lib/assess/sinks/index.js +1 -1
- package/lib/assess/sinks/libxmljs-xxe.js +2 -2
- package/lib/assess/sinks/mongodb.js +3 -2
- package/lib/assess/sinks/ssrf-url.js +2 -2
- package/lib/assess/sources/formidable.js +1 -1
- package/lib/assess/sources/index.js +1 -1
- package/lib/assess/static/hardcoded.js +1 -1
- package/lib/assess/technologies/index.js +1 -1
- package/lib/assess/utils.js +1 -1
- package/lib/cli-rewriter/index.js +1 -1
- package/lib/constants.js +5 -2
- package/lib/contrast.js +1 -1
- package/lib/core/arch-components/dynamodb.js +1 -1
- package/lib/core/arch-components/dynamodbv3.js +1 -1
- package/lib/core/arch-components/index.js +1 -1
- package/lib/core/arch-components/mongodb.js +1 -1
- package/lib/core/arch-components/mysql.js +1 -1
- package/lib/core/arch-components/postgres.js +1 -1
- package/lib/core/arch-components/rethinkdb.js +53 -0
- package/lib/core/arch-components/sqlite3.js +1 -1
- package/lib/core/async-storage/context.js +1 -1
- package/lib/core/async-storage/hooks/bluebird.js +1 -1
- package/lib/core/async-storage/hooks/mongodb-core.js +1 -1
- package/lib/core/async-storage/hooks/mysql.js +1 -1
- package/lib/core/async-storage/hooks/redis.js +1 -1
- package/lib/core/async-storage/hooks/utils.js +1 -1
- package/lib/core/async-storage/index.js +1 -1
- package/lib/core/async-storage/scopes/index.js +1 -1
- package/lib/core/common/formidable.js +1 -1
- package/lib/core/common/index.js +1 -1
- package/lib/core/config/options.js +4 -3
- package/lib/core/config/util.js +1 -1
- package/lib/core/exclusions/exclusion-factory.js +1 -1
- package/lib/core/exclusions/exclusion.js +1 -1
- package/lib/core/exclusions/input.js +1 -1
- package/lib/core/exclusions/url.js +1 -1
- package/lib/core/express/index.js +1 -1
- package/lib/core/express/utils.js +1 -1
- package/lib/core/fastify/index.js +1 -1
- package/lib/core/fastify/utils.js +1 -1
- package/lib/core/hapi/index.js +1 -1
- package/lib/core/hapi/utils.js +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/koa/index.js +1 -1
- package/lib/core/koa/utils.js +1 -1
- package/lib/core/logger/daily-rotate-file.js +1 -1
- package/lib/core/logger/dataflow-monitor.js +1 -1
- package/lib/core/logger/debug-logger.js +1 -1
- package/lib/core/logger/index.js +1 -1
- package/lib/core/logger/perf-logger.js +1 -1
- package/lib/core/logger/umbrella-logger.js +1 -1
- package/lib/core/loopback4/index.js +1 -1
- package/lib/core/metrics/index.js +1 -1
- package/lib/core/restify/index.js +1 -1
- package/lib/core/restify/utils.js +1 -1
- package/lib/core/rewrite/assignment-expression.js +1 -1
- package/lib/core/rewrite/binary-expression.js +1 -1
- package/lib/core/rewrite/call-expression.js +1 -1
- package/lib/core/rewrite/callees.js +1 -1
- package/lib/core/rewrite/catch-clause.js +1 -1
- package/lib/core/rewrite/function-wrap.js +1 -1
- package/lib/core/rewrite/index.js +1 -1
- package/lib/core/rewrite/injections.js +9 -1
- package/lib/core/rewrite/is-contrast-method.js +1 -1
- package/lib/core/rewrite/log.js +1 -1
- package/lib/core/rewrite/member-expression.js +1 -1
- package/lib/core/rewrite/object-property.js +1 -1
- package/lib/core/rewrite/prepend-globals.js +1 -1
- package/lib/core/rewrite/rewrite-log.js +1 -1
- package/lib/core/rewrite/switch-statement.js +1 -1
- package/lib/core/rewrite/template-literal.js +1 -1
- package/lib/core/stacktrace.js +3 -2
- package/lib/coverage.js +1 -1
- package/lib/feature-set.js +2 -2
- package/lib/generator-function.js +1 -1
- package/lib/hooks/array.js +1 -1
- package/lib/hooks/cluster.js +1 -1
- package/lib/hooks/dataflow-monitor.js +1 -1
- package/lib/hooks/encoding.js +1 -1
- package/lib/hooks/express-fileupload.js +1 -1
- package/lib/hooks/express-session.js +1 -1
- package/lib/hooks/fn-to-string.js +1 -1
- package/lib/hooks/frameworks/base.js +9 -3
- package/lib/hooks/frameworks/common.js +1 -1
- package/lib/hooks/frameworks/hapi16.js +1 -1
- package/lib/hooks/frameworks/http.js +24 -17
- package/lib/hooks/frameworks/http2.js +73 -0
- package/lib/hooks/frameworks/index.js +9 -4
- package/lib/hooks/hapi-16-reply.js +1 -1
- package/lib/hooks/hapi-16-session.js +1 -1
- package/lib/hooks/http.js +113 -129
- package/lib/hooks/module/extensions.js +1 -1
- package/lib/hooks/module/helpers.js +1 -1
- package/lib/hooks/module/index.js +1 -1
- package/lib/hooks/newrelic.js +1 -1
- package/lib/hooks/object-is.js +1 -1
- package/lib/hooks/object-to-primitive.js +7 -8
- package/lib/hooks/patcher.js +62 -39
- package/lib/hooks/require.js +17 -23
- package/lib/hooks/stealthy-require.js +1 -1
- package/lib/instrumentation.js +1 -4
- package/lib/libraries.js +1 -1
- package/lib/library-usage.js +1 -1
- package/lib/list-installed.js +1 -1
- package/lib/protect/analysis/aho-corasick.js +1 -1
- package/lib/protect/analysis/dfsa-analyzer.js +1 -1
- package/lib/protect/errors/handler.js +1 -1
- package/lib/protect/errors/security-exception.js +1 -1
- package/lib/protect/express/index.js +1 -1
- package/lib/protect/express/sinks.js +1 -1
- package/lib/protect/express/sources.js +1 -1
- package/lib/protect/fastify/index.js +1 -1
- package/lib/protect/fastify/sinks.js +1 -1
- package/lib/protect/fastify/sources.js +1 -1
- package/lib/protect/hapi/error-handler.js +1 -1
- package/lib/protect/hapi/index.js +1 -1
- package/lib/protect/hapi/sinks.js +1 -1
- package/lib/protect/hapi/sources.js +1 -1
- package/lib/protect/index.js +1 -1
- package/lib/protect/input-analysis.js +1 -1
- package/lib/protect/koa/index.js +1 -1
- package/lib/protect/koa/sinks.js +1 -1
- package/lib/protect/koa/sources.js +1 -1
- package/lib/protect/listeners.js +1 -1
- package/lib/protect/loopback4/index.js +1 -1
- package/lib/protect/loopback4/sources.js +1 -1
- package/lib/protect/models/application-context.js +1 -1
- package/lib/protect/models/sink-event.js +1 -1
- package/lib/protect/models/source-event.js +1 -1
- package/lib/protect/restify/index.js +1 -1
- package/lib/protect/restify/sinks.js +1 -1
- package/lib/protect/restify/sources.js +1 -1
- package/lib/protect/rules/assessment.js +1 -1
- package/lib/protect/rules/attack-patterns.js +1 -1
- package/lib/protect/rules/base-scanner/index.js +1 -1
- package/lib/protect/rules/base-scanner/java-script-scanner.js +1 -1
- package/lib/protect/rules/base-scanner/postgresqlscanner.js +1 -1
- package/lib/protect/rules/base-scanner/scan-state.js +1 -1
- package/lib/protect/rules/base-scanner/substring-finder.js +1 -1
- package/lib/protect/rules/base-scanner/token-sequence.js +1 -1
- package/lib/protect/rules/bot-blocker/bot-blocker-rule.js +1 -1
- package/lib/protect/rules/bot-blocker/index.js +1 -1
- package/lib/protect/rules/cmd-injection/cmdinjection-rule.js +1 -1
- package/lib/protect/rules/cmd-injection-command-backdoors/backdoor-detector.js +1 -1
- package/lib/protect/rules/cmd-injection-command-backdoors/cmd-injection-command-backdoors-rule.js +1 -1
- package/lib/protect/rules/cmd-injection-semantic-chained-commands/chained-command-scanner.js +1 -1
- package/lib/protect/rules/cmd-injection-semantic-chained-commands/cmd-injection-semantic-chained-commands-rule.js +1 -1
- package/lib/protect/rules/cmd-injection-semantic-dangerous-paths/cmd-injection-semantic-dangerous-paths-rule.js +1 -1
- package/lib/protect/rules/cmd-injection-semantic-dangerous-paths/dangerous-paths-scanner.js +1 -1
- package/lib/protect/rules/common.js +1 -1
- package/lib/protect/rules/index.js +1 -1
- package/lib/protect/rules/ip-denylist/ip-denylist-rule.js +1 -1
- package/lib/protect/rules/method-tampering/evaluator.js +1 -1
- package/lib/protect/rules/method-tampering/method-tampering-rule.js +1 -1
- package/lib/protect/rules/nosqli/nosql-injection-rule.js +228 -0
- package/lib/protect/rules/nosqli/nosql-scanner/index.js +1 -1
- package/lib/protect/rules/nosqli/nosql-scanner/mongodbscanner.js +1 -1
- package/lib/protect/rules/path-traversal/path-traversal-rule.js +1 -1
- package/lib/protect/rules/rule-factory.js +3 -3
- package/lib/protect/rules/signatures/cmd-injection/custom-searchers/chained-command-searcher.js +1 -1
- package/lib/protect/rules/signatures/cmd-injection/custom-searchers/index.js +1 -1
- package/lib/protect/rules/signatures/cmd-injection/index.js +1 -1
- package/lib/protect/rules/signatures/evaluator.js +1 -1
- package/lib/protect/rules/signatures/index.js +1 -1
- package/lib/protect/rules/signatures/nosql-injection/custom-searchers/index.js +1 -1
- package/lib/protect/rules/signatures/nosql-injection/custom-searchers/nosql-comment-searcher.js +1 -1
- package/lib/protect/rules/signatures/nosql-injection/custom-searchers/simple-or-searcher.js +1 -1
- package/lib/protect/rules/signatures/nosql-injection/index.js +1 -1
- package/lib/protect/rules/signatures/path-traversal/index.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/custom-searchers/behavior-url-searcher.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/custom-searchers/function-definition-searcher.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/custom-searchers/immediate-function-searcher.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/custom-searchers/index.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/custom-searchers/link-and-src-target-searcher.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/custom-searchers/location-set-searcher.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/custom-searchers/map-access-searcher.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/custom-searchers/native-function-execution-searcher.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/custom-searchers/no-alnum-searcher.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/custom-searchers/redefined-function-searcher.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/custom-searchers/style-url-injection-searcher.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/custom-searchers/variable-assignment-searcher.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/helpers/function-call.js +1 -1
- package/lib/protect/rules/signatures/reflected-xss/index.js +1 -1
- package/lib/protect/rules/signatures/signature.js +1 -1
- package/lib/protect/rules/signatures/sql-injection/custom-searchers/if-else-drop-searcher.js +1 -1
- package/lib/protect/rules/signatures/sql-injection/custom-searchers/index.js +1 -1
- package/lib/protect/rules/signatures/sql-injection/custom-searchers/simple-or-searcher.js +1 -1
- package/lib/protect/rules/signatures/sql-injection/custom-searchers/sql-comment-searcher.js +1 -1
- package/lib/protect/rules/signatures/sql-injection/custom-searchers/time-function-searcher.js +1 -1
- package/lib/protect/rules/signatures/sql-injection/custom-searchers/tsql-exec-searcher.js +1 -1
- package/lib/protect/rules/signatures/sql-injection/index.js +1 -1
- package/lib/protect/rules/signatures/ssjs-injection/index.js +1 -1
- package/lib/protect/rules/signatures/unsafe-file-upload/index.js +1 -1
- package/lib/protect/rules/signatures/untrusted-deserialization/index.js +1 -1
- package/lib/protect/rules/sqli/generic-complicated.js +1 -1
- package/lib/protect/rules/sqli/sql-injection-rule.js +1 -1
- package/lib/protect/rules/sqli/sql-scanner/index.js +1 -1
- package/lib/protect/rules/sqli/sql-scanner/mysql-scanner.js +1 -1
- package/lib/protect/rules/ssjs-injection/evaluator.js +1 -1
- package/lib/protect/rules/ssjs-injection/ssjsinjection-rule.js +1 -1
- package/lib/protect/rules/unsafe-file-upload/unsafe-file-upload-rule.js +1 -1
- package/lib/protect/rules/untrusted-deserialization/untrusted-deserialization-rule.js +1 -1
- package/lib/protect/rules/virtual-patch/index.js +1 -1
- package/lib/protect/rules/virtual-patch/utils.js +1 -1
- package/lib/protect/rules/virtual-patch/virtual-patch-rule.js +1 -1
- package/lib/protect/rules/xss/helpers/function-call.js +1 -1
- package/lib/protect/rules/xss/reflected-xss-rule.js +1 -1
- package/lib/protect/rules/xxe/xxerule.js +1 -1
- package/lib/protect/sample-aggregator.js +1 -1
- package/lib/protect/samples.js +1 -1
- package/lib/protect/service.js +24 -12
- package/lib/protect/sinks/child-process.js +1 -1
- package/lib/protect/sinks/eval.js +1 -1
- package/lib/protect/sinks/fs.js +1 -1
- package/lib/protect/sinks/function.js +1 -1
- package/lib/protect/sinks/index.js +1 -1
- package/lib/protect/sinks/libxmljs.js +1 -1
- package/lib/protect/sinks/mongodb.js +57 -56
- package/lib/protect/sinks/mysql.js +1 -1
- package/lib/protect/sinks/node-serialize.js +1 -1
- package/lib/protect/sinks/postgres.js +1 -1
- package/lib/protect/sinks/sequelize.js +1 -1
- package/lib/protect/sinks/sqlite3.js +1 -1
- package/lib/protect/sinks/vm.js +1 -1
- package/lib/protect/sources/busboy.js +1 -1
- package/lib/protect/sources/formidable.js +1 -1
- package/lib/protect/sources/index.js +1 -1
- package/lib/protect/validators/authorization.js +1 -1
- package/lib/protect/validators/common.js +1 -1
- package/lib/protect/validators/connection.js +1 -1
- package/lib/protect/validators/content-length.js +1 -1
- package/lib/protect/validators/host.js +1 -1
- package/lib/protect/validators/if-none-match.js +1 -1
- package/lib/protect/validators/index.js +1 -1
- package/lib/protect/validators/origin.js +1 -1
- package/lib/reporter/app-activity-queue.js +1 -1
- package/lib/reporter/grpc-client.js +1 -1
- package/lib/reporter/messages/speedracer/activity.js +1 -1
- package/lib/reporter/messages/speedracer/application-create.js +1 -1
- package/lib/reporter/messages/speedracer/application-update.js +1 -1
- package/lib/reporter/messages/speedracer/base.js +1 -1
- package/lib/reporter/messages/speedracer/index.js +1 -1
- package/lib/reporter/messages/speedracer/observed-route.js +1 -1
- package/lib/reporter/messages/speedracer/poll.js +1 -1
- package/lib/reporter/messages/speedracer/request.js +1 -1
- package/lib/reporter/messages/speedracer/startup.js +1 -1
- package/lib/reporter/messaging-router.js +1 -1
- package/lib/reporter/models/app-activity/app-activity.js +1 -1
- package/lib/reporter/models/app-activity/attacker-activity.js +1 -1
- package/lib/reporter/models/app-activity/defend.js +1 -1
- package/lib/reporter/models/app-activity/inventory.js +1 -1
- package/lib/reporter/models/app-activity/protection-rule-activity.js +1 -1
- package/lib/reporter/models/app-activity/rule-events.js +1 -1
- package/lib/reporter/models/app-activity/sample.js +1 -1
- package/lib/reporter/models/app-activity/source.js +1 -1
- package/lib/reporter/models/app-activity/user-input.js +1 -1
- package/lib/reporter/models/app-create.js +1 -1
- package/lib/reporter/models/app-update/index.js +1 -1
- package/lib/reporter/models/app-update/library-manifest.js +1 -1
- package/lib/reporter/models/app-update/library-usage.js +1 -1
- package/lib/reporter/models/app-update/library.js +1 -1
- package/lib/reporter/models/event-tag.js +1 -1
- package/lib/reporter/models/finding/event.js +1 -1
- package/lib/reporter/models/finding/finding.js +1 -1
- package/lib/reporter/models/frameworks/express-request.js +1 -1
- package/lib/reporter/models/frameworks/fastify-request.js +1 -1
- package/lib/reporter/models/frameworks/hapi-request.js +1 -1
- package/lib/reporter/models/frameworks/index.js +1 -1
- package/lib/reporter/models/frameworks/koa-request.js +1 -1
- package/lib/reporter/models/frameworks/restify-request.js +1 -1
- package/lib/reporter/models/observed-route.js +1 -1
- package/lib/reporter/models/request.js +1 -1
- package/lib/reporter/models/route-coverage.js +1 -1
- package/lib/reporter/models/startup.js +1 -1
- package/lib/reporter/models/trace-event-source.js +1 -1
- package/lib/reporter/models/utils/request-factory.js +1 -1
- package/lib/reporter/models/utils/user-input-factory.js +1 -1
- package/lib/reporter/models/utils/user-input-kit.js +1 -1
- package/lib/reporter/mq-client.js +1 -1
- package/lib/reporter/server-activity-queue.js +1 -1
- package/lib/reporter/socket-client.js +1 -1
- package/lib/reporter/speedracer/base-connection-state.js +1 -1
- package/lib/reporter/speedracer/constants.js +1 -1
- package/lib/reporter/speedracer/failure-connection-state.js +1 -1
- package/lib/reporter/speedracer/index.js +1 -1
- package/lib/reporter/speedracer/success-connection-state.js +1 -1
- package/lib/reporter/speedracer/unknown-connection-state.js +1 -1
- package/lib/reporter/translations/enums.js +1 -1
- package/lib/reporter/translations/helpers.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/activity.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/address.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/agent-startup.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/application-create.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/application-update.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/architecture-component.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/attack-result.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/bot-blocker-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/cmd-injection-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/cmd-injection-semantic-analysis-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/finding.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/http-method-tampering-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/http-request.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/index.js +2 -2
- package/lib/reporter/translations/to-protobuf/dtm/ip-denylist-details.js +2 -2
- package/lib/reporter/translations/to-protobuf/dtm/library-usage-update.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/no-sql-injection-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/observed-route.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/pair.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/path-traversal-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/poll.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/rasp-rule-sample.js +2 -2
- package/lib/reporter/translations/to-protobuf/dtm/raw-request.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/route-coverage.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/simple-pair.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/sql-injection-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/ssjs-injection-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/stack-trace-element.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/trace-event/action.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/trace-event/index.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/trace-event/parent-object-id.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/trace-event/trace-event-object.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/trace-event/trace-event-signature.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/trace-event/trace-event-source.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/trace-event/trace-stack.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/trace-event/trace-taint-range.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/trace-event/type.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/untrusted-deserialization-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/user-input.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/virtual-patch-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/xss-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/dtm/xxe-details.js +1 -1
- package/lib/reporter/translations/to-protobuf/index.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/application-settings.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/assess-features.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/auth.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/bot-blocker.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/custom-rule-feature.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/defend-features.js +9 -7
- package/lib/reporter/translations/to-protobuf/settings/exclusions.js +6 -5
- package/lib/reporter/translations/to-protobuf/settings/index.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/input-analysis-result.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/inventory-features.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/ip-filter.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/log-enhancer.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/protection-rule.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/reaction.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/rule-definition.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/sampling.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/server-features.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/syslog.js +1 -1
- package/lib/reporter/translations/to-protobuf/settings/virtual-patch.js +1 -1
- package/lib/reporter/ts-reporter.js +1 -1
- package/lib/tracker.js +14 -66
- package/lib/util/base64.js +1 -1
- package/lib/util/bitset.js +1 -1
- package/lib/util/block-request.js +1 -1
- package/lib/util/callback-resolver.js +1 -1
- package/lib/util/clean-stack.js +1 -1
- package/lib/util/clean-string/brackets.js +1 -1
- package/lib/util/clean-string/clean-string-base.js +1 -1
- package/lib/util/clean-string/comments.js +1 -1
- package/lib/util/clean-string/concatenations.js +1 -1
- package/lib/util/clean-string/jsclean-string.js +1 -1
- package/lib/util/clean-string/placeholders.js +1 -1
- package/lib/util/clean-string/util.js +1 -1
- package/lib/util/colors.js +1 -1
- package/lib/util/file-finder.js +1 -1
- package/lib/util/heap-dump.js +1 -1
- package/lib/util/html-util.js +1 -1
- package/lib/util/ip-analyzer.js +1 -1
- package/lib/util/is-agent-path.js +1 -1
- package/lib/util/is-contrast-error.js +1 -1
- package/lib/util/is-piped-to-dev.js +1 -1
- package/lib/util/is-string.js +1 -1
- package/lib/util/partial.js +1 -1
- package/lib/util/pkg-name.js +1 -1
- package/lib/util/request-util.js +1 -1
- package/lib/util/resolve-obj.js +1 -1
- package/lib/util/route-info.js +1 -1
- package/lib/util/some.js +1 -1
- package/lib/util/source-map.js +2 -2
- package/lib/util/static-rules.js +1 -1
- package/lib/util/trace-util.js +1 -1
- package/lib/util/traverse.js +1 -1
- package/lib/util/user-input-evaluator.js +1 -1
- package/lib/util/xml-analyzer/external-entity-finder.js +1 -1
- package/package.json +14 -16
- package/perf-logs.js +1 -1
- package/lib/hooks/frameworks/https.js +0 -42
- package/lib/protect/rules/nosqli/no-sql-injection-rule.js +0 -109
- package/node_modules/bindings/LICENSE.md +0 -22
- package/node_modules/bindings/README.md +0 -98
- package/node_modules/bindings/bindings.js +0 -221
- package/node_modules/bindings/package.json +0 -32
- package/node_modules/file-uri-to-path/.npmignore +0 -1
- package/node_modules/file-uri-to-path/.travis.yml +0 -30
- package/node_modules/file-uri-to-path/History.md +0 -21
- package/node_modules/file-uri-to-path/LICENSE +0 -20
- package/node_modules/file-uri-to-path/README.md +0 -74
- package/node_modules/file-uri-to-path/index.d.ts +0 -2
- package/node_modules/file-uri-to-path/index.js +0 -66
- package/node_modules/file-uri-to-path/package.json +0 -36
- package/node_modules/file-uri-to-path/test/test.js +0 -24
- package/node_modules/file-uri-to-path/test/tests.json +0 -13
- package/node_modules/glossy/LICENSE +0 -19
- package/node_modules/glossy/README.md +0 -129
- package/node_modules/glossy/index.js +0 -12
- package/node_modules/glossy/lib/glossy/parse.js +0 -520
- package/node_modules/glossy/lib/glossy/produce.js +0 -459
- package/node_modules/glossy/package.json +0 -47
- package/node_modules/glossy/test/decide.js +0 -7
- package/node_modules/glossy/test/decode_pri.js +0 -24
- package/node_modules/glossy/test/parse_3164.js +0 -104
- package/node_modules/glossy/test/parse_5424.js +0 -106
- package/node_modules/glossy/test/parse_5848.js +0 -40
- package/node_modules/glossy/test/parse_8601.js +0 -14
- package/node_modules/glossy/test/parse_rfc3339.js +0 -9
- package/node_modules/glossy/test/produce.js +0 -162
- package/node_modules/glossy/test/runner.js +0 -40
- package/node_modules/glossy/test/structure_data.js +0 -24
- package/node_modules/nan/CHANGELOG.md +0 -537
- package/node_modules/nan/LICENSE.md +0 -13
- package/node_modules/nan/README.md +0 -455
- package/node_modules/nan/doc/asyncworker.md +0 -146
- package/node_modules/nan/doc/buffers.md +0 -54
- package/node_modules/nan/doc/callback.md +0 -76
- package/node_modules/nan/doc/converters.md +0 -41
- package/node_modules/nan/doc/errors.md +0 -226
- package/node_modules/nan/doc/json.md +0 -62
- package/node_modules/nan/doc/maybe_types.md +0 -583
- package/node_modules/nan/doc/methods.md +0 -664
- package/node_modules/nan/doc/new.md +0 -147
- package/node_modules/nan/doc/node_misc.md +0 -123
- package/node_modules/nan/doc/object_wrappers.md +0 -263
- package/node_modules/nan/doc/persistent.md +0 -296
- package/node_modules/nan/doc/scopes.md +0 -73
- package/node_modules/nan/doc/script.md +0 -38
- package/node_modules/nan/doc/string_bytes.md +0 -62
- package/node_modules/nan/doc/v8_internals.md +0 -199
- package/node_modules/nan/doc/v8_misc.md +0 -85
- package/node_modules/nan/include_dirs.js +0 -1
- package/node_modules/nan/nan.h +0 -2898
- package/node_modules/nan/nan_callbacks.h +0 -88
- package/node_modules/nan/nan_callbacks_12_inl.h +0 -514
- package/node_modules/nan/nan_callbacks_pre_12_inl.h +0 -520
- package/node_modules/nan/nan_converters.h +0 -72
- package/node_modules/nan/nan_converters_43_inl.h +0 -68
- package/node_modules/nan/nan_converters_pre_43_inl.h +0 -42
- package/node_modules/nan/nan_define_own_property_helper.h +0 -29
- package/node_modules/nan/nan_implementation_12_inl.h +0 -430
- package/node_modules/nan/nan_implementation_pre_12_inl.h +0 -263
- package/node_modules/nan/nan_json.h +0 -166
- package/node_modules/nan/nan_maybe_43_inl.h +0 -356
- package/node_modules/nan/nan_maybe_pre_43_inl.h +0 -268
- package/node_modules/nan/nan_new.h +0 -340
- package/node_modules/nan/nan_object_wrap.h +0 -156
- package/node_modules/nan/nan_persistent_12_inl.h +0 -132
- package/node_modules/nan/nan_persistent_pre_12_inl.h +0 -242
- package/node_modules/nan/nan_private.h +0 -73
- package/node_modules/nan/nan_string_bytes.h +0 -305
- package/node_modules/nan/nan_typedarray_contents.h +0 -96
- package/node_modules/nan/nan_weak.h +0 -437
- package/node_modules/nan/package.json +0 -41
- package/node_modules/nan/tools/1to2.js +0 -412
- package/node_modules/nan/tools/README.md +0 -14
- package/node_modules/nan/tools/package.json +0 -19
- package/node_modules/unix-dgram/LICENSE +0 -13
- package/node_modules/unix-dgram/README.md +0 -107
- package/node_modules/unix-dgram/binding.gyp +0 -20
- package/node_modules/unix-dgram/build/Makefile +0 -324
- package/node_modules/unix-dgram/build/Release/.deps/Release/obj.target/unix_dgram/src/unix_dgram.o.d +0 -58
- package/node_modules/unix-dgram/build/Release/.deps/Release/obj.target/unix_dgram.node.d +0 -1
- package/node_modules/unix-dgram/build/Release/.deps/Release/unix_dgram.node.d +0 -1
- package/node_modules/unix-dgram/build/Release/obj.target/unix_dgram/src/unix_dgram.o +0 -0
- package/node_modules/unix-dgram/build/Release/obj.target/unix_dgram.node +0 -0
- package/node_modules/unix-dgram/build/Release/unix_dgram.node +0 -0
- package/node_modules/unix-dgram/build/binding.Makefile +0 -6
- package/node_modules/unix-dgram/build/config.gypi +0 -213
- package/node_modules/unix-dgram/build/unix_dgram.target.mk +0 -159
- package/node_modules/unix-dgram/lib/unix_dgram.js +0 -168
- package/node_modules/unix-dgram/package.json +0 -36
- package/node_modules/unix-dgram/src/unix_dgram.cc +0 -404
- package/node_modules/unix-dgram/src/win_dummy.cc +0 -7
- package/node_modules/unix-dgram/test/test-connect-callback.js +0 -68
- package/node_modules/unix-dgram/test/test-connect.js +0 -53
- package/node_modules/unix-dgram/test/test-dgram-unix.js +0 -58
- package/node_modules/unix-dgram/test/test-send-error.js +0 -26
- package/node_modules/winston-syslog/.eslintrc +0 -7
- package/node_modules/winston-syslog/.travis.yml +0 -14
- package/node_modules/winston-syslog/CHANGELOG.md +0 -9
- package/node_modules/winston-syslog/LICENSE +0 -20
- package/node_modules/winston-syslog/README.md +0 -135
- package/node_modules/winston-syslog/lib/utils.js +0 -26
- package/node_modules/winston-syslog/lib/winston-syslog.js +0 -385
- package/node_modules/winston-syslog/package.json +0 -56
- package/node_modules/winston-syslog/test/format-test.js +0 -122
- package/node_modules/winston-syslog/test/syslog-test.js +0 -95
- package/node_modules/winston-syslog/test/unix-connect-test.js +0 -133
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
/*********************************************************************
|
|
2
|
-
* NAN - Native Abstractions for Node.js
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2018 NAN contributors
|
|
5
|
-
*
|
|
6
|
-
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
|
7
|
-
********************************************************************/
|
|
8
|
-
|
|
9
|
-
#ifndef NAN_PERSISTENT_PRE_12_INL_H_
|
|
10
|
-
#define NAN_PERSISTENT_PRE_12_INL_H_
|
|
11
|
-
|
|
12
|
-
template<typename T>
|
|
13
|
-
class PersistentBase {
|
|
14
|
-
v8::Persistent<T> persistent;
|
|
15
|
-
template<typename U>
|
|
16
|
-
friend v8::Local<U> New(const PersistentBase<U> &p);
|
|
17
|
-
template<typename U, typename M>
|
|
18
|
-
friend v8::Local<U> New(const Persistent<U, M> &p);
|
|
19
|
-
template<typename U>
|
|
20
|
-
friend v8::Local<U> New(const Global<U> &p);
|
|
21
|
-
template<typename S> friend class ReturnValue;
|
|
22
|
-
|
|
23
|
-
public:
|
|
24
|
-
inline PersistentBase() :
|
|
25
|
-
persistent() {}
|
|
26
|
-
|
|
27
|
-
inline void Reset() {
|
|
28
|
-
persistent.Dispose();
|
|
29
|
-
persistent.Clear();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
template<typename S>
|
|
33
|
-
inline void Reset(const v8::Local<S> &other) {
|
|
34
|
-
TYPE_CHECK(T, S);
|
|
35
|
-
|
|
36
|
-
if (!persistent.IsEmpty()) {
|
|
37
|
-
persistent.Dispose();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (other.IsEmpty()) {
|
|
41
|
-
persistent.Clear();
|
|
42
|
-
} else {
|
|
43
|
-
persistent = v8::Persistent<T>::New(other);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
template<typename S>
|
|
48
|
-
inline void Reset(const PersistentBase<S> &other) {
|
|
49
|
-
TYPE_CHECK(T, S);
|
|
50
|
-
|
|
51
|
-
if (!persistent.IsEmpty()) {
|
|
52
|
-
persistent.Dispose();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (other.IsEmpty()) {
|
|
56
|
-
persistent.Clear();
|
|
57
|
-
} else {
|
|
58
|
-
persistent = v8::Persistent<T>::New(other.persistent);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
inline bool IsEmpty() const { return persistent.IsEmpty(); }
|
|
63
|
-
|
|
64
|
-
inline void Empty() { persistent.Clear(); }
|
|
65
|
-
|
|
66
|
-
template<typename S>
|
|
67
|
-
inline bool operator==(const PersistentBase<S> &that) const {
|
|
68
|
-
return this->persistent == that.persistent;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
template<typename S>
|
|
72
|
-
inline bool operator==(const v8::Local<S> &that) const {
|
|
73
|
-
return this->persistent == that;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
template<typename S>
|
|
77
|
-
inline bool operator!=(const PersistentBase<S> &that) const {
|
|
78
|
-
return !operator==(that);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
template<typename S>
|
|
82
|
-
inline bool operator!=(const v8::Local<S> &that) const {
|
|
83
|
-
return !operator==(that);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
template<typename P>
|
|
87
|
-
inline void SetWeak(
|
|
88
|
-
P *parameter
|
|
89
|
-
, typename WeakCallbackInfo<P>::Callback callback
|
|
90
|
-
, WeakCallbackType type);
|
|
91
|
-
|
|
92
|
-
inline void ClearWeak() { persistent.ClearWeak(); }
|
|
93
|
-
|
|
94
|
-
inline void MarkIndependent() { persistent.MarkIndependent(); }
|
|
95
|
-
|
|
96
|
-
inline bool IsIndependent() const { return persistent.IsIndependent(); }
|
|
97
|
-
|
|
98
|
-
inline bool IsNearDeath() const { return persistent.IsNearDeath(); }
|
|
99
|
-
|
|
100
|
-
inline bool IsWeak() const { return persistent.IsWeak(); }
|
|
101
|
-
|
|
102
|
-
private:
|
|
103
|
-
inline explicit PersistentBase(v8::Persistent<T> that) :
|
|
104
|
-
persistent(that) { }
|
|
105
|
-
inline explicit PersistentBase(T *val) : persistent(val) {}
|
|
106
|
-
template<typename S, typename M> friend class Persistent;
|
|
107
|
-
template<typename S> friend class Global;
|
|
108
|
-
friend class ObjectWrap;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
template<typename T>
|
|
112
|
-
class NonCopyablePersistentTraits {
|
|
113
|
-
public:
|
|
114
|
-
typedef Persistent<T, NonCopyablePersistentTraits<T> >
|
|
115
|
-
NonCopyablePersistent;
|
|
116
|
-
static const bool kResetInDestructor = false;
|
|
117
|
-
template<typename S, typename M>
|
|
118
|
-
inline static void Copy(const Persistent<S, M> &source,
|
|
119
|
-
NonCopyablePersistent *dest) {
|
|
120
|
-
Uncompilable<v8::Object>();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
template<typename O> inline static void Uncompilable() {
|
|
124
|
-
TYPE_CHECK(O, v8::Primitive);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
template<typename T>
|
|
129
|
-
struct CopyablePersistentTraits {
|
|
130
|
-
typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
|
|
131
|
-
static const bool kResetInDestructor = true;
|
|
132
|
-
template<typename S, typename M>
|
|
133
|
-
static inline void Copy(const Persistent<S, M> &source,
|
|
134
|
-
CopyablePersistent *dest) {}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
template<typename T, typename M> class Persistent :
|
|
138
|
-
public PersistentBase<T> {
|
|
139
|
-
public:
|
|
140
|
-
inline Persistent() {}
|
|
141
|
-
|
|
142
|
-
template<typename S> inline Persistent(v8::Handle<S> that)
|
|
143
|
-
: PersistentBase<T>(v8::Persistent<T>::New(that)) {
|
|
144
|
-
TYPE_CHECK(T, S);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
inline Persistent(const Persistent &that) : PersistentBase<T>() {
|
|
148
|
-
Copy(that);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
template<typename S, typename M2>
|
|
152
|
-
inline Persistent(const Persistent<S, M2> &that) :
|
|
153
|
-
PersistentBase<T>() {
|
|
154
|
-
Copy(that);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
inline Persistent &operator=(const Persistent &that) {
|
|
158
|
-
Copy(that);
|
|
159
|
-
return *this;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
template <class S, class M2>
|
|
163
|
-
inline Persistent &operator=(const Persistent<S, M2> &that) {
|
|
164
|
-
Copy(that);
|
|
165
|
-
return *this;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
inline ~Persistent() {
|
|
169
|
-
if (M::kResetInDestructor) this->Reset();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
private:
|
|
173
|
-
inline T *operator*() const { return *PersistentBase<T>::persistent; }
|
|
174
|
-
|
|
175
|
-
template<typename S, typename M2>
|
|
176
|
-
inline void Copy(const Persistent<S, M2> &that) {
|
|
177
|
-
TYPE_CHECK(T, S);
|
|
178
|
-
|
|
179
|
-
this->Reset();
|
|
180
|
-
|
|
181
|
-
if (!that.IsEmpty()) {
|
|
182
|
-
this->persistent = v8::Persistent<T>::New(that.persistent);
|
|
183
|
-
M::Copy(that, this);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
template<typename T>
|
|
189
|
-
class Global : public PersistentBase<T> {
|
|
190
|
-
struct RValue {
|
|
191
|
-
inline explicit RValue(Global* obj) : object(obj) {}
|
|
192
|
-
Global* object;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
public:
|
|
196
|
-
inline Global() : PersistentBase<T>(0) { }
|
|
197
|
-
|
|
198
|
-
template <typename S>
|
|
199
|
-
inline Global(v8::Local<S> that) // NOLINT(runtime/explicit)
|
|
200
|
-
: PersistentBase<T>(v8::Persistent<T>::New(that)) {
|
|
201
|
-
TYPE_CHECK(T, S);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
template <typename S>
|
|
205
|
-
inline Global(const PersistentBase<S> &that) // NOLINT(runtime/explicit)
|
|
206
|
-
: PersistentBase<T>(that) {
|
|
207
|
-
TYPE_CHECK(T, S);
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Move constructor.
|
|
211
|
-
*/
|
|
212
|
-
inline Global(RValue rvalue) // NOLINT(runtime/explicit)
|
|
213
|
-
: PersistentBase<T>(rvalue.object->persistent) {
|
|
214
|
-
rvalue.object->Reset();
|
|
215
|
-
}
|
|
216
|
-
inline ~Global() { this->Reset(); }
|
|
217
|
-
/**
|
|
218
|
-
* Move via assignment.
|
|
219
|
-
*/
|
|
220
|
-
template<typename S>
|
|
221
|
-
inline Global &operator=(Global<S> rhs) {
|
|
222
|
-
TYPE_CHECK(T, S);
|
|
223
|
-
this->Reset(rhs.persistent);
|
|
224
|
-
rhs.Reset();
|
|
225
|
-
return *this;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Cast operator for moves.
|
|
229
|
-
*/
|
|
230
|
-
inline operator RValue() { return RValue(this); }
|
|
231
|
-
/**
|
|
232
|
-
* Pass allows returning uniques from functions, etc.
|
|
233
|
-
*/
|
|
234
|
-
Global Pass() { return Global(RValue(this)); }
|
|
235
|
-
|
|
236
|
-
private:
|
|
237
|
-
Global(Global &);
|
|
238
|
-
void operator=(Global &);
|
|
239
|
-
template<typename S> friend class ReturnValue;
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
#endif // NAN_PERSISTENT_PRE_12_INL_H_
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/*********************************************************************
|
|
2
|
-
* NAN - Native Abstractions for Node.js
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2018 NAN contributors
|
|
5
|
-
*
|
|
6
|
-
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
|
7
|
-
********************************************************************/
|
|
8
|
-
|
|
9
|
-
#ifndef NAN_PRIVATE_H_
|
|
10
|
-
#define NAN_PRIVATE_H_
|
|
11
|
-
|
|
12
|
-
inline Maybe<bool>
|
|
13
|
-
HasPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key) {
|
|
14
|
-
HandleScope scope;
|
|
15
|
-
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
|
16
|
-
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
|
17
|
-
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
18
|
-
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
|
19
|
-
return object->HasPrivate(context, private_key);
|
|
20
|
-
#else
|
|
21
|
-
return Just(!object->GetHiddenValue(key).IsEmpty());
|
|
22
|
-
#endif
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
inline MaybeLocal<v8::Value>
|
|
26
|
-
GetPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key) {
|
|
27
|
-
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
|
28
|
-
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
|
29
|
-
v8::EscapableHandleScope scope(isolate);
|
|
30
|
-
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
31
|
-
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
|
32
|
-
v8::MaybeLocal<v8::Value> v = object->GetPrivate(context, private_key);
|
|
33
|
-
return scope.Escape(v.ToLocalChecked());
|
|
34
|
-
#else
|
|
35
|
-
EscapableHandleScope scope;
|
|
36
|
-
v8::Local<v8::Value> v = object->GetHiddenValue(key);
|
|
37
|
-
if (v.IsEmpty()) {
|
|
38
|
-
v = Undefined();
|
|
39
|
-
}
|
|
40
|
-
return scope.Escape(v);
|
|
41
|
-
#endif
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
inline Maybe<bool> SetPrivate(
|
|
45
|
-
v8::Local<v8::Object> object,
|
|
46
|
-
v8::Local<v8::String> key,
|
|
47
|
-
v8::Local<v8::Value> value) {
|
|
48
|
-
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
|
49
|
-
HandleScope scope;
|
|
50
|
-
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
|
51
|
-
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
52
|
-
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
|
53
|
-
return object->SetPrivate(context, private_key, value);
|
|
54
|
-
#else
|
|
55
|
-
return Just(object->SetHiddenValue(key, value));
|
|
56
|
-
#endif
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
inline Maybe<bool> DeletePrivate(
|
|
60
|
-
v8::Local<v8::Object> object,
|
|
61
|
-
v8::Local<v8::String> key) {
|
|
62
|
-
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
|
63
|
-
HandleScope scope;
|
|
64
|
-
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
|
65
|
-
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
|
66
|
-
return object->DeletePrivate(isolate->GetCurrentContext(), private_key);
|
|
67
|
-
#else
|
|
68
|
-
return Just(object->DeleteHiddenValue(key));
|
|
69
|
-
#endif
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
#endif // NAN_PRIVATE_H_
|
|
73
|
-
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
// Copyright Joyent, Inc. and other Node contributors.
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
4
|
-
// 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 permit
|
|
8
|
-
// persons to whom the Software is furnished to do so, subject to the
|
|
9
|
-
// following conditions:
|
|
10
|
-
//
|
|
11
|
-
// The above copyright notice and this permission notice shall be included
|
|
12
|
-
// in all copies or substantial portions of the Software.
|
|
13
|
-
//
|
|
14
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
15
|
-
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
17
|
-
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
19
|
-
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
20
|
-
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
-
|
|
22
|
-
#ifndef NAN_STRING_BYTES_H_
|
|
23
|
-
#define NAN_STRING_BYTES_H_
|
|
24
|
-
|
|
25
|
-
// Decodes a v8::Local<v8::String> or Buffer to a raw char*
|
|
26
|
-
|
|
27
|
-
namespace imp {
|
|
28
|
-
|
|
29
|
-
using v8::Local;
|
|
30
|
-
using v8::Object;
|
|
31
|
-
using v8::String;
|
|
32
|
-
using v8::Value;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
//// Base 64 ////
|
|
36
|
-
|
|
37
|
-
#define base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
//// HEX ////
|
|
42
|
-
|
|
43
|
-
static bool contains_non_ascii_slow(const char* buf, size_t len) {
|
|
44
|
-
for (size_t i = 0; i < len; ++i) {
|
|
45
|
-
if (buf[i] & 0x80) return true;
|
|
46
|
-
}
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
static bool contains_non_ascii(const char* src, size_t len) {
|
|
52
|
-
if (len < 16) {
|
|
53
|
-
return contains_non_ascii_slow(src, len);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const unsigned bytes_per_word = sizeof(void*);
|
|
57
|
-
const unsigned align_mask = bytes_per_word - 1;
|
|
58
|
-
const unsigned unaligned = reinterpret_cast<uintptr_t>(src) & align_mask;
|
|
59
|
-
|
|
60
|
-
if (unaligned > 0) {
|
|
61
|
-
const unsigned n = bytes_per_word - unaligned;
|
|
62
|
-
if (contains_non_ascii_slow(src, n)) return true;
|
|
63
|
-
src += n;
|
|
64
|
-
len -= n;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
#if defined(__x86_64__) || defined(_WIN64)
|
|
69
|
-
const uintptr_t mask = 0x8080808080808080ll;
|
|
70
|
-
#else
|
|
71
|
-
const uintptr_t mask = 0x80808080l;
|
|
72
|
-
#endif
|
|
73
|
-
|
|
74
|
-
const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(src);
|
|
75
|
-
|
|
76
|
-
for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) {
|
|
77
|
-
if (srcw[i] & mask) return true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const unsigned remainder = len & align_mask;
|
|
81
|
-
if (remainder > 0) {
|
|
82
|
-
const size_t offset = len - remainder;
|
|
83
|
-
if (contains_non_ascii_slow(src + offset, remainder)) return true;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
static void force_ascii_slow(const char* src, char* dst, size_t len) {
|
|
91
|
-
for (size_t i = 0; i < len; ++i) {
|
|
92
|
-
dst[i] = src[i] & 0x7f;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
static void force_ascii(const char* src, char* dst, size_t len) {
|
|
98
|
-
if (len < 16) {
|
|
99
|
-
force_ascii_slow(src, dst, len);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const unsigned bytes_per_word = sizeof(void*);
|
|
104
|
-
const unsigned align_mask = bytes_per_word - 1;
|
|
105
|
-
const unsigned src_unalign = reinterpret_cast<uintptr_t>(src) & align_mask;
|
|
106
|
-
const unsigned dst_unalign = reinterpret_cast<uintptr_t>(dst) & align_mask;
|
|
107
|
-
|
|
108
|
-
if (src_unalign > 0) {
|
|
109
|
-
if (src_unalign == dst_unalign) {
|
|
110
|
-
const unsigned unalign = bytes_per_word - src_unalign;
|
|
111
|
-
force_ascii_slow(src, dst, unalign);
|
|
112
|
-
src += unalign;
|
|
113
|
-
dst += unalign;
|
|
114
|
-
len -= src_unalign;
|
|
115
|
-
} else {
|
|
116
|
-
force_ascii_slow(src, dst, len);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
#if defined(__x86_64__) || defined(_WIN64)
|
|
122
|
-
const uintptr_t mask = ~0x8080808080808080ll;
|
|
123
|
-
#else
|
|
124
|
-
const uintptr_t mask = ~0x80808080l;
|
|
125
|
-
#endif
|
|
126
|
-
|
|
127
|
-
const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(src);
|
|
128
|
-
uintptr_t* dstw = reinterpret_cast<uintptr_t*>(dst);
|
|
129
|
-
|
|
130
|
-
for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) {
|
|
131
|
-
dstw[i] = srcw[i] & mask;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const unsigned remainder = len & align_mask;
|
|
135
|
-
if (remainder > 0) {
|
|
136
|
-
const size_t offset = len - remainder;
|
|
137
|
-
force_ascii_slow(src + offset, dst + offset, remainder);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
static size_t base64_encode(const char* src,
|
|
143
|
-
size_t slen,
|
|
144
|
-
char* dst,
|
|
145
|
-
size_t dlen) {
|
|
146
|
-
// We know how much we'll write, just make sure that there's space.
|
|
147
|
-
assert(dlen >= base64_encoded_size(slen) &&
|
|
148
|
-
"not enough space provided for base64 encode");
|
|
149
|
-
|
|
150
|
-
dlen = base64_encoded_size(slen);
|
|
151
|
-
|
|
152
|
-
unsigned a;
|
|
153
|
-
unsigned b;
|
|
154
|
-
unsigned c;
|
|
155
|
-
unsigned i;
|
|
156
|
-
unsigned k;
|
|
157
|
-
unsigned n;
|
|
158
|
-
|
|
159
|
-
static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
160
|
-
"abcdefghijklmnopqrstuvwxyz"
|
|
161
|
-
"0123456789+/";
|
|
162
|
-
|
|
163
|
-
i = 0;
|
|
164
|
-
k = 0;
|
|
165
|
-
n = slen / 3 * 3;
|
|
166
|
-
|
|
167
|
-
while (i < n) {
|
|
168
|
-
a = src[i + 0] & 0xff;
|
|
169
|
-
b = src[i + 1] & 0xff;
|
|
170
|
-
c = src[i + 2] & 0xff;
|
|
171
|
-
|
|
172
|
-
dst[k + 0] = table[a >> 2];
|
|
173
|
-
dst[k + 1] = table[((a & 3) << 4) | (b >> 4)];
|
|
174
|
-
dst[k + 2] = table[((b & 0x0f) << 2) | (c >> 6)];
|
|
175
|
-
dst[k + 3] = table[c & 0x3f];
|
|
176
|
-
|
|
177
|
-
i += 3;
|
|
178
|
-
k += 4;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (n != slen) {
|
|
182
|
-
switch (slen - n) {
|
|
183
|
-
case 1:
|
|
184
|
-
a = src[i + 0] & 0xff;
|
|
185
|
-
dst[k + 0] = table[a >> 2];
|
|
186
|
-
dst[k + 1] = table[(a & 3) << 4];
|
|
187
|
-
dst[k + 2] = '=';
|
|
188
|
-
dst[k + 3] = '=';
|
|
189
|
-
break;
|
|
190
|
-
|
|
191
|
-
case 2:
|
|
192
|
-
a = src[i + 0] & 0xff;
|
|
193
|
-
b = src[i + 1] & 0xff;
|
|
194
|
-
dst[k + 0] = table[a >> 2];
|
|
195
|
-
dst[k + 1] = table[((a & 3) << 4) | (b >> 4)];
|
|
196
|
-
dst[k + 2] = table[(b & 0x0f) << 2];
|
|
197
|
-
dst[k + 3] = '=';
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return dlen;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) {
|
|
207
|
-
// We know how much we'll write, just make sure that there's space.
|
|
208
|
-
assert(dlen >= slen * 2 &&
|
|
209
|
-
"not enough space provided for hex encode");
|
|
210
|
-
|
|
211
|
-
dlen = slen * 2;
|
|
212
|
-
for (uint32_t i = 0, k = 0; k < dlen; i += 1, k += 2) {
|
|
213
|
-
static const char hex[] = "0123456789abcdef";
|
|
214
|
-
uint8_t val = static_cast<uint8_t>(src[i]);
|
|
215
|
-
dst[k + 0] = hex[val >> 4];
|
|
216
|
-
dst[k + 1] = hex[val & 15];
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return dlen;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
static Local<Value> Encode(const char* buf,
|
|
225
|
-
size_t buflen,
|
|
226
|
-
enum Encoding encoding) {
|
|
227
|
-
assert(buflen <= node::Buffer::kMaxLength);
|
|
228
|
-
if (!buflen && encoding != BUFFER)
|
|
229
|
-
return New("").ToLocalChecked();
|
|
230
|
-
|
|
231
|
-
Local<String> val;
|
|
232
|
-
switch (encoding) {
|
|
233
|
-
case BUFFER:
|
|
234
|
-
return CopyBuffer(buf, buflen).ToLocalChecked();
|
|
235
|
-
|
|
236
|
-
case ASCII:
|
|
237
|
-
if (contains_non_ascii(buf, buflen)) {
|
|
238
|
-
char* out = new char[buflen];
|
|
239
|
-
force_ascii(buf, out, buflen);
|
|
240
|
-
val = New<String>(out, buflen).ToLocalChecked();
|
|
241
|
-
delete[] out;
|
|
242
|
-
} else {
|
|
243
|
-
val = New<String>(buf, buflen).ToLocalChecked();
|
|
244
|
-
}
|
|
245
|
-
break;
|
|
246
|
-
|
|
247
|
-
case UTF8:
|
|
248
|
-
val = New<String>(buf, buflen).ToLocalChecked();
|
|
249
|
-
break;
|
|
250
|
-
|
|
251
|
-
case BINARY: {
|
|
252
|
-
// TODO(isaacs) use ExternalTwoByteString?
|
|
253
|
-
const unsigned char *cbuf = reinterpret_cast<const unsigned char*>(buf);
|
|
254
|
-
uint16_t * twobytebuf = new uint16_t[buflen];
|
|
255
|
-
for (size_t i = 0; i < buflen; i++) {
|
|
256
|
-
// XXX is the following line platform independent?
|
|
257
|
-
twobytebuf[i] = cbuf[i];
|
|
258
|
-
}
|
|
259
|
-
val = New<String>(twobytebuf, buflen).ToLocalChecked();
|
|
260
|
-
delete[] twobytebuf;
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
case BASE64: {
|
|
265
|
-
size_t dlen = base64_encoded_size(buflen);
|
|
266
|
-
char* dst = new char[dlen];
|
|
267
|
-
|
|
268
|
-
size_t written = base64_encode(buf, buflen, dst, dlen);
|
|
269
|
-
assert(written == dlen);
|
|
270
|
-
|
|
271
|
-
val = New<String>(dst, dlen).ToLocalChecked();
|
|
272
|
-
delete[] dst;
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
case UCS2: {
|
|
277
|
-
const uint16_t* data = reinterpret_cast<const uint16_t*>(buf);
|
|
278
|
-
val = New<String>(data, buflen / 2).ToLocalChecked();
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
case HEX: {
|
|
283
|
-
size_t dlen = buflen * 2;
|
|
284
|
-
char* dst = new char[dlen];
|
|
285
|
-
size_t written = hex_encode(buf, buflen, dst, dlen);
|
|
286
|
-
assert(written == dlen);
|
|
287
|
-
|
|
288
|
-
val = New<String>(dst, dlen).ToLocalChecked();
|
|
289
|
-
delete[] dst;
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
default:
|
|
294
|
-
assert(0 && "unknown encoding");
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return val;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
#undef base64_encoded_size
|
|
302
|
-
|
|
303
|
-
} // end of namespace imp
|
|
304
|
-
|
|
305
|
-
#endif // NAN_STRING_BYTES_H_
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/*********************************************************************
|
|
2
|
-
* NAN - Native Abstractions for Node.js
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2018 NAN contributors
|
|
5
|
-
*
|
|
6
|
-
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
|
7
|
-
********************************************************************/
|
|
8
|
-
|
|
9
|
-
#ifndef NAN_TYPEDARRAY_CONTENTS_H_
|
|
10
|
-
#define NAN_TYPEDARRAY_CONTENTS_H_
|
|
11
|
-
|
|
12
|
-
template<typename T>
|
|
13
|
-
class TypedArrayContents {
|
|
14
|
-
public:
|
|
15
|
-
inline explicit TypedArrayContents(v8::Local<v8::Value> from) :
|
|
16
|
-
length_(0), data_(NULL) {
|
|
17
|
-
HandleScope scope;
|
|
18
|
-
|
|
19
|
-
size_t length = 0;
|
|
20
|
-
void* data = NULL;
|
|
21
|
-
|
|
22
|
-
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
|
23
|
-
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
|
24
|
-
|
|
25
|
-
if (from->IsArrayBufferView()) {
|
|
26
|
-
v8::Local<v8::ArrayBufferView> array =
|
|
27
|
-
v8::Local<v8::ArrayBufferView>::Cast(from);
|
|
28
|
-
|
|
29
|
-
const size_t byte_length = array->ByteLength();
|
|
30
|
-
const ptrdiff_t byte_offset = array->ByteOffset();
|
|
31
|
-
v8::Local<v8::ArrayBuffer> buffer = array->Buffer();
|
|
32
|
-
|
|
33
|
-
length = byte_length / sizeof(T);
|
|
34
|
-
// Actually it's 7.9 here but this would lead to ABI issues with Node.js 13
|
|
35
|
-
// using 7.8 till 13.2.0.
|
|
36
|
-
#if (V8_MAJOR_VERSION >= 8)
|
|
37
|
-
data = static_cast<char*>(buffer->GetBackingStore()->Data()) + byte_offset;
|
|
38
|
-
#else
|
|
39
|
-
data = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
|
|
40
|
-
#endif
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
#else
|
|
44
|
-
|
|
45
|
-
if (from->IsObject() && !from->IsNull()) {
|
|
46
|
-
v8::Local<v8::Object> array = v8::Local<v8::Object>::Cast(from);
|
|
47
|
-
|
|
48
|
-
MaybeLocal<v8::Value> buffer = Get(array,
|
|
49
|
-
New<v8::String>("buffer").ToLocalChecked());
|
|
50
|
-
MaybeLocal<v8::Value> byte_length = Get(array,
|
|
51
|
-
New<v8::String>("byteLength").ToLocalChecked());
|
|
52
|
-
MaybeLocal<v8::Value> byte_offset = Get(array,
|
|
53
|
-
New<v8::String>("byteOffset").ToLocalChecked());
|
|
54
|
-
|
|
55
|
-
if (!buffer.IsEmpty() &&
|
|
56
|
-
!byte_length.IsEmpty() && byte_length.ToLocalChecked()->IsUint32() &&
|
|
57
|
-
!byte_offset.IsEmpty() && byte_offset.ToLocalChecked()->IsUint32()) {
|
|
58
|
-
data = array->GetIndexedPropertiesExternalArrayData();
|
|
59
|
-
if(data) {
|
|
60
|
-
length = byte_length.ToLocalChecked()->Uint32Value() / sizeof(T);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
#endif
|
|
66
|
-
|
|
67
|
-
#if defined(_MSC_VER) && _MSC_VER >= 1900 || __cplusplus >= 201103L
|
|
68
|
-
assert(reinterpret_cast<uintptr_t>(data) % alignof (T) == 0);
|
|
69
|
-
#elif defined(_MSC_VER) && _MSC_VER >= 1600 || defined(__GNUC__)
|
|
70
|
-
assert(reinterpret_cast<uintptr_t>(data) % __alignof(T) == 0);
|
|
71
|
-
#else
|
|
72
|
-
assert(reinterpret_cast<uintptr_t>(data) % sizeof (T) == 0);
|
|
73
|
-
#endif
|
|
74
|
-
|
|
75
|
-
length_ = length;
|
|
76
|
-
data_ = static_cast<T*>(data);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
inline size_t length() const { return length_; }
|
|
80
|
-
inline T* operator*() { return data_; }
|
|
81
|
-
inline const T* operator*() const { return data_; }
|
|
82
|
-
|
|
83
|
-
private:
|
|
84
|
-
NAN_DISALLOW_ASSIGN_COPY_MOVE(TypedArrayContents)
|
|
85
|
-
|
|
86
|
-
//Disable heap allocation
|
|
87
|
-
void *operator new(size_t size);
|
|
88
|
-
void operator delete(void *, size_t) {
|
|
89
|
-
abort();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
size_t length_;
|
|
93
|
-
T* data_;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
#endif // NAN_TYPEDARRAY_CONTENTS_H_
|