Move IntrusivePtr and utility methods to the zeek namespace

This commit is contained in:
Tim Wojtulewicz 2020-06-24 16:40:00 -04:00
parent 4668378d91
commit 9364e6a5b7
255 changed files with 3761 additions and 3730 deletions

View file

@ -11,12 +11,12 @@
#include <openssl/err.h>
// construct an error record
static IntrusivePtr<RecordVal> x509_result_record(uint64_t num, const char* reason, IntrusivePtr<Val> chainVector = nullptr)
static zeek::IntrusivePtr<RecordVal> x509_result_record(uint64_t num, const char* reason, zeek::IntrusivePtr<Val> chainVector = nullptr)
{
auto rrecord = make_intrusive<RecordVal>(zeek::BifType::Record::X509::Result);
auto rrecord = zeek::make_intrusive<RecordVal>(zeek::BifType::Record::X509::Result);
rrecord->Assign(0, val_mgr->Int(num));
rrecord->Assign(1, make_intrusive<StringVal>(reason));
rrecord->Assign(1, zeek::make_intrusive<StringVal>(reason));
if ( chainVector )
rrecord->Assign(2, std::move(chainVector));
@ -161,7 +161,7 @@ function x509_parse%(cert: opaque of x509%): X509::Certificate
function x509_from_der%(der: string%): opaque of x509
%{
const u_char* data = der->Bytes();
return make_intrusive<file_analysis::X509Val>(d2i_X509(nullptr, &data, der->Len()));
return zeek::make_intrusive<file_analysis::X509Val>(d2i_X509(nullptr, &data, der->Len()));
%}
## Returns the string form of a certificate.
@ -215,7 +215,7 @@ function x509_get_certificate_string%(cert: opaque of x509, pem: bool &default=F
## x509_get_certificate_string x509_verify
function x509_ocsp_verify%(certs: x509_opaque_vector, ocsp_reply: string, root_certs: table_string_of_string, verify_time: time &default=network_time()%): X509::Result
%{
IntrusivePtr<RecordVal> rval;
zeek::IntrusivePtr<RecordVal> rval;
X509_STORE* ctx = ::file_analysis::X509::GetRootStore(root_certs->AsTableVal());
if ( ! ctx )
return x509_result_record(-1, "Problem initializing root store");
@ -542,7 +542,7 @@ function x509_verify%(certs: x509_opaque_vector, root_certs: table_string_of_str
int result = X509_verify_cert(csc);
IntrusivePtr<VectorVal> chainVector;
zeek::IntrusivePtr<VectorVal> chainVector;
if ( result == 1 ) // we have a valid chain. try to get it...
{
@ -556,7 +556,7 @@ function x509_verify%(certs: x509_opaque_vector, root_certs: table_string_of_str
}
int num_certs = sk_X509_num(chain);
chainVector = make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("x509_opaque_vector"));
chainVector = zeek::make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("x509_opaque_vector"));
for ( int i = 0; i < num_certs; i++ )
{
@ -564,7 +564,7 @@ function x509_verify%(certs: x509_opaque_vector, root_certs: table_string_of_str
if ( currcert )
// X509Val takes ownership of currcert.
chainVector->Assign(i, make_intrusive<file_analysis::X509Val>(currcert));
chainVector->Assign(i, zeek::make_intrusive<file_analysis::X509Val>(currcert));
else
{
reporter->InternalWarning("OpenSSL returned null certificate");
@ -761,7 +761,7 @@ sct_verify_err:
* 1 -> issuer name
* 2 -> pubkey
*/
IntrusivePtr<StringVal> x509_entity_hash(file_analysis::X509Val *cert_handle, unsigned int hash_alg, unsigned int type)
zeek::IntrusivePtr<StringVal> x509_entity_hash(file_analysis::X509Val *cert_handle, unsigned int hash_alg, unsigned int type)
{
assert(cert_handle);
@ -824,7 +824,7 @@ IntrusivePtr<StringVal> x509_entity_hash(file_analysis::X509Val *cert_handle, un
assert( len <= sizeof(md) );
return make_intrusive<StringVal>(len, reinterpret_cast<const char*>(md));
return zeek::make_intrusive<StringVal>(len, reinterpret_cast<const char*>(md));
}
%%}
@ -900,7 +900,7 @@ function x509_spki_hash%(cert: opaque of x509, hash_alg: count%): string
## .. zeek:see:: x509_set_certificate_cache_hit_callback
function x509_set_certificate_cache%(tbl: string_any_table%) : bool
%{
file_analysis::X509::SetCertificateCache({NewRef{}, tbl->AsTableVal()});
file_analysis::X509::SetCertificateCache({zeek::NewRef{}, tbl->AsTableVal()});
return val_mgr->True();
%}
@ -918,7 +918,7 @@ function x509_set_certificate_cache%(tbl: string_any_table%) : bool
## .. zeek:see:: x509_set_certificate_cache
function x509_set_certificate_cache_hit_callback%(f: string_any_file_hook%) : bool
%{
file_analysis::X509::SetCertificateCacheHitCallback({NewRef{}, f->AsFunc()});
file_analysis::X509::SetCertificateCacheHitCallback({zeek::NewRef{}, f->AsFunc()});
return val_mgr->True();
%}