Node.js  v8.x
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine
node_revert.h
Go to the documentation of this file.
1 #ifndef SRC_NODE_REVERT_H_
2 #define SRC_NODE_REVERT_H_
3 
4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5 
6 #include "node.h"
7 
16 namespace node {
17 
18 #define SECURITY_REVERSIONS(XX)
19 // XX(CVE_2016_PEND, "CVE-2016-PEND", "Vulnerability Title")
20 
21 enum reversion {
22 #define V(code, ...) SECURITY_REVERT_##code,
23  SECURITY_REVERSIONS(V)
24 #undef V
25 };
26 
27 extern unsigned int reverted;
28 
29 inline const char* RevertMessage(const reversion cve) {
30 #define V(code, label, msg) case SECURITY_REVERT_##code: return label ": " msg;
31  switch (cve) {
32  SECURITY_REVERSIONS(V)
33  default:
34  return "Unknown";
35  }
36 #undef V
37 }
38 
39 inline void Revert(const reversion cve) {
40  reverted |= 1 << cve;
41  printf("SECURITY WARNING: Reverting %s\n", RevertMessage(cve));
42 }
43 
44 inline void Revert(const char* cve) {
45 #define V(code, label, _) \
46  if (strcmp(cve, label) == 0) return Revert(SECURITY_REVERT_##code);
47  SECURITY_REVERSIONS(V)
48 #undef V
49  printf("Error: Attempt to revert an unknown CVE [%s]\n", cve);
50  exit(12);
51 }
52 
53 inline bool IsReverted(const reversion cve) {
54  return reverted & (1 << cve);
55 }
56 
57 inline bool IsReverted(const char* cve) {
58 #define V(code, label, _) \
59  if (strcmp(cve, label) == 0) return IsReverted(SECURITY_REVERT_##code);
60  SECURITY_REVERSIONS(V)
61  return false;
62 #undef V
63 }
64 
65 } // namespace node
66 
67 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
68 
69 #endif // SRC_NODE_REVERT_H_
#define V(PROVIDER)
unsigned int reverted
Definition: node.cc:189