Skip to content

Commit

Permalink
adding api - scan_pdf_api
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Andreu committed Aug 26, 2016
1 parent 84356c3 commit 3a55eb8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
45 changes: 45 additions & 0 deletions bayshore_content_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,51 @@ void find_open_office_embeddings(void *membuf, size_t size, std::list<std::strin
}
//////////////////////////////////////////////////////////////

/************
scan_pdf_api
*************/


void scan_pdf_api(void *cookie,
std::list<security_scan_results_t> *ssr_list,
const char *src,
const char *child_file_name,
void (*cb)(void*, std::list<security_scan_results_t> *, const char *),
int in_type_of_scan
)
{
security_scan_parameters_t *ssp_local = (security_scan_parameters_t *)cookie;

size_t src_len = strlen(src);
/*
* declare str_buf here so that it doesnt go
* out of scope when "if (in_type_of_scan == 1)"
* completes
*/
std::string str_buf;

if (in_type_of_scan == 1) {
PDFParser pdf;
str_buf = pdf.extract_text_buffer(ssp_local->buffer, ssp_local->buffer_length);

ssp_local->buffer = (const uint8_t*)str_buf.c_str();
ssp_local->buffer_length = str_buf.length();
}

if (src_len == 0) {
snprintf (ssp_local->scan_type, sizeof(ssp_local->scan_type), "%s %s", type_of_scan[in_type_of_scan], "(PDF)");
} else {
snprintf (ssp_local->scan_type, sizeof(ssp_local->scan_type), "%s %s%s", type_of_scan[in_type_of_scan], "(PDF)", src);
}

if (child_file_name)
cb((void *)ssp_local, ssr_list, child_file_name);
else
cb((void *)ssp_local, ssr_list, "");

}



/************************
scan_office_open_xml_api
Expand Down
1 change: 1 addition & 0 deletions bayshore_content_scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void scan_content (const uint8_t *, size_t, YR_RULES *, std::list<security_scan_


// by type (used by the API entry points)
void scan_pdf_api(void *, std::list<security_scan_results_t> *, const char *, const char *, void (*cb)(void*, std::list<security_scan_results_t> *, const char *), int);
void scan_office_open_xml_api(void *, std::list<security_scan_results_t> *, const char *, const char *, bool, void (*cb)(void*, std::list<security_scan_results_t> *, const char *), int);


Expand Down

0 comments on commit 3a55eb8

Please sign in to comment.