mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-19 04:00:01 +01:00
Merge #14696: qa: Add explicit references to related CVE's in p2p_invalid_block test.
0c62e3aa73New regression testing for CVE-2018-17144, CVE-2012-2459, and CVE-2010-5137. (lucash-dev)38bfca6bb2Added comments referencing multiple CVEs in tests and production code. (lucash-dev) Pull request description: This functional test includes two scenarios that test for regressions of vulnerabilities, but they are only briefly described. There are freely available documents explaining in detail the issues, but without explicit mentions, the developer trying to maintain the code needs an additional step of digging in commit history and PR conversations to figure it out. Added comments to explicitly mention CVE-2018-17144 and CVE-2012-2459, for more complete documentation. This improves developer experience by making understanding the tests easier. ACKs for top commit: laanwj: ACK0c62e3aa73, checked the CVE numbers, thanks for adding documentation Tree-SHA512: 3ee05351745193b8b959e4a25d50f25a693b2d24b0732ed53cf7d5882df40b5dd0f1877bd5c69cffb921d4a7acf9deb3cc1160b96dc730d9b5984151ad06b7c9
This commit is contained in:
@@ -24,7 +24,24 @@ import abc
|
||||
from test_framework.messages import CTransaction, CTxIn, CTxOut, COutPoint
|
||||
from test_framework import script as sc
|
||||
from test_framework.blocktools import create_tx_with_script, MAX_BLOCK_SIGOPS
|
||||
|
||||
from test_framework.script import (
|
||||
CScript,
|
||||
OP_CAT,
|
||||
OP_SUBSTR,
|
||||
OP_LEFT,
|
||||
OP_RIGHT,
|
||||
OP_INVERT,
|
||||
OP_AND,
|
||||
OP_OR,
|
||||
OP_XOR,
|
||||
OP_2MUL,
|
||||
OP_2DIV,
|
||||
OP_MUL,
|
||||
OP_DIV,
|
||||
OP_MOD,
|
||||
OP_LSHIFT,
|
||||
OP_RSHIFT
|
||||
)
|
||||
basic_p2sh = sc.CScript([sc.OP_HASH160, sc.hash160(sc.CScript([sc.OP_0])), sc.OP_EQUAL])
|
||||
|
||||
|
||||
@@ -178,7 +195,44 @@ class TooManySigops(BadTxTemplate):
|
||||
script_pub_key=lotsa_checksigs,
|
||||
amount=1)
|
||||
|
||||
def getDisabledOpcodeTemplate(opcode):
|
||||
""" Creates disabled opcode tx template class"""
|
||||
def get_tx(self):
|
||||
tx = CTransaction()
|
||||
vin = self.valid_txin
|
||||
vin.scriptSig = CScript([opcode])
|
||||
tx.vin.append(vin)
|
||||
tx.vout.append(CTxOut(1, basic_p2sh))
|
||||
tx.calc_sha256()
|
||||
return tx
|
||||
|
||||
return type('DisabledOpcode_' + str(opcode), (BadTxTemplate,), {
|
||||
'reject_reason': "disabled opcode",
|
||||
'expect_disconnect': True,
|
||||
'get_tx': get_tx,
|
||||
'valid_in_block' : True
|
||||
})
|
||||
|
||||
# Disabled opcode tx templates (CVE-2010-5137)
|
||||
DisabledOpcodeTemplates = [getDisabledOpcodeTemplate(opcode) for opcode in [
|
||||
OP_CAT,
|
||||
OP_SUBSTR,
|
||||
OP_LEFT,
|
||||
OP_RIGHT,
|
||||
OP_INVERT,
|
||||
OP_AND,
|
||||
OP_OR,
|
||||
OP_XOR,
|
||||
OP_2MUL,
|
||||
OP_2DIV,
|
||||
OP_MUL,
|
||||
OP_DIV,
|
||||
OP_MOD,
|
||||
OP_LSHIFT,
|
||||
OP_RSHIFT]]
|
||||
|
||||
|
||||
def iter_all_templates():
|
||||
"""Iterate through all bad transaction template types."""
|
||||
return BadTxTemplate.__subclasses__()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user