Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavkor <david@adalogics.com>2020-08-13 19:12:44 +0300
committerRich Trott <rtrott@gmail.com>2020-08-16 00:59:07 +0300
commit375b859428e1c525f0cc9d3c4324f51740316722 (patch)
tree6f193b56793b3ed58522ecee321d732a69b3c54b
parent5d179cb2eccac38205b6f03ecf6403df65deea51 (diff)
build: add build flag for OSS-Fuzz integration
Refs: https://github.com/google/oss-fuzz/pull/3860 Fixes: https://github.com/nodejs/node/issues/33724 PR-URL: https://github.com/nodejs/node/pull/34761 Fixes: https://github.com/nodejs/node/issues/33724 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com>
-rwxr-xr-xconfigure.py8
-rw-r--r--node.gyp33
-rw-r--r--test/fuzzers/fuzz_url.cc11
3 files changed, 52 insertions, 0 deletions
diff --git a/configure.py b/configure.py
index fc702ce06fb..5134892cb52 100755
--- a/configure.py
+++ b/configure.py
@@ -439,6 +439,11 @@ parser.add_option('--v8-options',
dest='v8_options',
help='v8 options to pass, see `node --v8-options` for examples.')
+parser.add_option('--with-ossfuzz',
+ action='store_true',
+ dest='ossfuzz',
+ help='Enables building of fuzzers. This command should be run in an OSS-Fuzz Docker image.')
+
parser.add_option('--with-arm-float-abi',
action='store',
dest='arm_float_abi',
@@ -1827,6 +1832,9 @@ configure_intl(output)
configure_static(output)
configure_inspector(output)
+# Forward OSS-Fuzz settings
+output['variables']['ossfuzz'] = b(options.ossfuzz)
+
# variables should be a root level element,
# move everything else to target_defaults
variables = output['variables']
diff --git a/node.gyp b/node.gyp
index f198bc6cf52..22c270123f1 100644
--- a/node.gyp
+++ b/node.gyp
@@ -13,6 +13,7 @@
'node_use_bundled_v8%': 'true',
'node_shared%': 'false',
'force_dynamic_crt%': 0,
+ 'ossfuzz' : 'false',
'node_module_version%': '',
'node_shared_brotli%': 'false',
'node_shared_zlib%': 'false',
@@ -1170,6 +1171,38 @@
} ],
]
}, # specialize_node_d
+ { # fuzz_url
+ 'target_name': 'fuzz_url',
+ 'type': 'executable',
+ 'dependencies': [
+ '<(node_lib_target_name)',
+ ],
+ 'includes': [
+ 'node.gypi'
+ ],
+ 'include_dirs': [
+ 'src',
+ ],
+ 'defines': [
+ 'NODE_ARCH="<(target_arch)"',
+ 'NODE_PLATFORM="<(OS)"',
+ 'NODE_WANT_INTERNALS=1',
+ ],
+ 'sources': [
+ 'src/node_snapshot_stub.cc',
+ 'src/node_code_cache_stub.cc',
+ 'test/fuzzers/fuzz_url.cc',
+ ],
+ 'conditions': [
+ ['OS=="linux"', {
+ 'ldflags': [ '-fsanitize=fuzzer' ]
+ }],
+ # Ensure that ossfuzz flag has been set and that we are on Linux
+ [ 'OS!="linux" or ossfuzz!="true"', {
+ 'type': 'none',
+ }],
+ ],
+ }, # fuzz_url
{
'target_name': 'cctest',
'type': 'executable',
diff --git a/test/fuzzers/fuzz_url.cc b/test/fuzzers/fuzz_url.cc
new file mode 100644
index 00000000000..16c5f644893
--- /dev/null
+++ b/test/fuzzers/fuzz_url.cc
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+
+#include "node.h"
+#include "node_internals.h"
+#include "node_url.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ node::url::URL url2(reinterpret_cast<const char*>(data), size);
+
+ return 0;
+}