Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add source info to TLS certificate assets and create them from host details #663

Merged
merged 36 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5865dd6
No longer use trashcan for TLS certificates
timopollmeier Jun 26, 2019
408cbcf
Add tls_certificates sha256 and serial, drop trash
timopollmeier Jun 27, 2019
c8f161f
Merge branch 'master' of github.com:greenbone/gvm into tls-certificat…
timopollmeier Jul 9, 2019
bb0c5cf
Merge branch 'master' of github.com:greenbone/gvm into tls-certificat…
timopollmeier Jul 11, 2019
019302d
Add parse_ssldetails function
timopollmeier Jul 12, 2019
c2bcf35
Init buffer_size in get_certificate_info
timopollmeier Jul 12, 2019
a2869ce
Move tls_certificate_format_str to manage.c
timopollmeier Jul 12, 2019
a1e2d39
Merge branch 'master' of github.com:greenbone/gvm into tls-certificat…
timopollmeier Jul 16, 2019
04f17b6
Add SHA-256, serial, sources to TLS certificates
timopollmeier Jul 16, 2019
3c6c13c
Migrate TLS certificates from host details
timopollmeier Jul 16, 2019
a01e48e
Add IF NOT EXISTS to tls_certificate_sources
timopollmeier Jul 16, 2019
193d152
Add tls_certificate SHA256 and serial to GMP
timopollmeier Jul 16, 2019
419774e
Change time helper functions to accept bigint
timopollmeier Jul 16, 2019
7271943
Add last_collected to TLS certificates
timopollmeier Jul 16, 2019
e53bbd7
Add sources to TLS certificates GMP
timopollmeier Jul 18, 2019
22dd7f0
Allow only to change name and comment of TLS certs
timopollmeier Jul 18, 2019
7376f39
Handle sources importing and deleting TLS certs
timopollmeier Jul 18, 2019
43a77b0
Check fingerprints when copying TLS certificates
timopollmeier Jul 18, 2019
cd0cbcd
Move TLS cert fingerprint checks to functions
timopollmeier Jul 18, 2019
d143d6f
Also copy sha256_fingerprint and serial
timopollmeier Jul 18, 2019
1dc11f8
Add function for TLS certificates from Base64 data
timopollmeier Jul 31, 2019
68be964
Merge branch 'master' of github.com:greenbone/gvm into tls-certificat…
timopollmeier Jul 31, 2019
56feb87
Move TLS certificate creation to new function
timopollmeier Aug 1, 2019
4d5f67f
Quote strings in TLS certificate helper functions
timopollmeier Aug 5, 2019
2737434
Document return value for make_tls_certificate
timopollmeier Aug 5, 2019
8e88b6c
Create TLS certificates from host details in scans
timopollmeier Aug 5, 2019
26ff6e6
Merge branch 'master' of github.com:greenbone/gvm into tls-certificat…
timopollmeier Aug 5, 2019
2fab871
Add CHANGELOG.md entry about TLS certificates
timopollmeier Aug 5, 2019
f2dd059
Clean up TLS certificate helper functions
timopollmeier Aug 5, 2019
38e18cd
Apply automatic formatting to gmp_get.h
timopollmeier Aug 5, 2019
d6a42a3
Merge branch 'master' into tls-certificate-assets
timopollmeier Aug 7, 2019
16640b2
Merge branch 'master' into tls-certificate-assets
mattmundell Aug 7, 2019
1910d90
Merge branch 'master' into tls-certificate-assets
mattmundell Aug 7, 2019
11d20b7
Move parse_ssldetails, tls_certificate_format_str
timopollmeier Aug 7, 2019
620ba4b
Clean up TLS certificate migrator functions
timopollmeier Aug 7, 2019
1e59119
Clean up create_tls_certificate GMP doc
timopollmeier Aug 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]

### Added
- Added TLS certificates as a new resource type [#585](https://github.com/greenbone/gvmd/pull/585) [#663](https://github.com/greenbone/gvmd/pull/663)
- Update NVTs via OSP [#392](https://github.com/greenbone/gvmd/pull/392) [#609](https://github.com/greenbone/gvmd/pull/609) [#626](https://github.com/greenbone/gvmd/pull/626)
- Handle addition of ID to NVT preferences. [#413](https://github.com/greenbone/gvmd/pull/413)
- Add setting 'OMP Slave Check Period' [#491](https://github.com/greenbone/gvmd/pull/491)
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ include (CPack)

## Variables

set (GVMD_DATABASE_VERSION 212)
set (GVMD_DATABASE_VERSION 214)

set (GVMD_SCAP_DATABASE_VERSION 15)

Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ add_executable (manage-utils-test
manage_sql.c manage_sql_nvts.c manage_sql_secinfo.c
manage_sql_configs.c
manage_sql_tickets.c manage_sql_tls_certificates.c
manage_tls_certificates.c
manage_migrators.c scanner.c
sql_pg.c manage_pg.c
lsc_user.c lsc_crypt.c utils.c comm.c
Expand All @@ -110,6 +111,7 @@ add_executable (manage-test
manage_sql.c manage_sql_nvts.c manage_sql_secinfo.c
manage_sql_configs.c
manage_sql_tickets.c manage_sql_tls_certificates.c
manage_tls_certificates.c
manage_migrators.c scanner.c
sql_pg.c manage_pg.c
lsc_user.c lsc_crypt.c utils.c comm.c
Expand All @@ -133,6 +135,7 @@ add_executable (gmp-tickets-test
manage_sql.c manage_sql_nvts.c manage_sql_secinfo.c
manage_sql_configs.c
manage_sql_tickets.c manage_sql_tls_certificates.c
manage_tls_certificates.c
manage_migrators.c scanner.c
sql_pg.c manage_pg.c
lsc_user.c lsc_crypt.c utils.c comm.c
Expand All @@ -156,6 +159,7 @@ add_executable (gvmd
manage_sql.c manage_sql_nvts.c manage_sql_secinfo.c
manage_sql_configs.c
manage_sql_tickets.c manage_sql_tls_certificates.c
manage_tls_certificates.c
manage_migrators.c scanner.c
sql_pg.c manage_pg.c
lsc_user.c lsc_crypt.c utils.c comm.c
Expand Down
102 changes: 72 additions & 30 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -13249,10 +13249,19 @@ handle_get_credentials (gmp_parser_t *gmp_parser, GError **error)
/* get certificate info */
time_t activation_time, expiration_time;
gchar *activation_time_str, *expiration_time_str;
gchar *fingerprint, *issuer;
get_certificate_info (cert, -1,
&activation_time, &expiration_time,
&fingerprint, NULL, &issuer, NULL);
gchar *md5_fingerprint, *issuer;

get_certificate_info (cert,
-1,
&activation_time,
&expiration_time,
&md5_fingerprint,
NULL, /* sha256_fingerprint */
NULL, /* subject */
&issuer,
NULL, /* serial */
NULL); /* certificate_format */

activation_time_str = certificate_iso_time (activation_time);
expiration_time_str = certificate_iso_time (expiration_time);
SENDF_TO_CLIENT_OR_FAIL
Expand All @@ -13266,11 +13275,11 @@ handle_get_credentials (gmp_parser_t *gmp_parser, GError **error)
certificate_time_status (activation_time, expiration_time),
activation_time_str,
expiration_time_str,
fingerprint ? fingerprint : "",
md5_fingerprint ? md5_fingerprint : "",
issuer ? issuer : "");
g_free (activation_time_str);
g_free (expiration_time_str);
g_free (fingerprint);
g_free (md5_fingerprint);
g_free (issuer);
}

Expand Down Expand Up @@ -16512,10 +16521,19 @@ handle_get_scanners (gmp_parser_t *gmp_parser, GError **error)
if (scanner_iterator_ca_pub (&scanners))
{
/* CA Certificate */
gchar *fingerprint, *issuer;
get_certificate_info (scanner_iterator_ca_pub (&scanners), -1,
&activation_time, &expiration_time,
&fingerprint, NULL, &issuer, NULL);
gchar *md5_fingerprint, *issuer;

get_certificate_info (scanner_iterator_ca_pub (&scanners),
-1,
&activation_time,
&expiration_time,
&md5_fingerprint,
NULL, /* sha256_fingerprint */
NULL, /* subject */
&issuer,
NULL, /* serial */
NULL); /* certificate_format */

activation_time_str = certificate_iso_time (activation_time);
expiration_time_str = certificate_iso_time (expiration_time);
SENDF_TO_CLIENT_OR_FAIL
Expand All @@ -16529,11 +16547,11 @@ handle_get_scanners (gmp_parser_t *gmp_parser, GError **error)
certificate_time_status (activation_time, expiration_time),
activation_time_str,
expiration_time_str,
fingerprint,
md5_fingerprint,
issuer);
g_free (activation_time_str);
g_free (expiration_time_str);
g_free (fingerprint);
g_free (md5_fingerprint);
g_free (issuer);
}
}
Expand All @@ -16557,10 +16575,19 @@ handle_get_scanners (gmp_parser_t *gmp_parser, GError **error)
if (scanner_iterator_key_pub (&scanners))
{
/* Certificate */
gchar *fingerprint, *issuer;
get_certificate_info (scanner_iterator_key_pub (&scanners), -1,
&activation_time, &expiration_time,
&fingerprint, NULL, &issuer, NULL);
gchar *md5_fingerprint, *issuer;

get_certificate_info (scanner_iterator_key_pub (&scanners),
-1,
&activation_time,
&expiration_time,
&md5_fingerprint,
NULL, /* sha256_fingerprint */
NULL, /* subject */
&issuer,
NULL, /* serial */
NULL); /* certificate_format */

activation_time_str = certificate_iso_time (activation_time);
expiration_time_str = certificate_iso_time (expiration_time);
SENDF_TO_CLIENT_OR_FAIL
Expand All @@ -16574,11 +16601,11 @@ handle_get_scanners (gmp_parser_t *gmp_parser, GError **error)
certificate_time_status (activation_time, expiration_time),
activation_time_str,
expiration_time_str,
fingerprint,
md5_fingerprint,
issuer);
g_free (activation_time_str);
g_free (expiration_time_str);
g_free (fingerprint);
g_free (md5_fingerprint);
g_free (issuer);
}
}
Expand Down Expand Up @@ -17433,13 +17460,20 @@ handle_get_settings (gmp_parser_t *gmp_parser, GError **error)
&& strlen (setting_iterator_value (&settings)))
{
time_t activation_time, expiration_time;
gchar *activation_time_str, *expiration_time_str, *fingerprint;
gchar *activation_time_str, *expiration_time_str, *md5_fingerprint;
gchar *issuer;

get_certificate_info (setting_iterator_value (&settings), -1,
get_certificate_info (setting_iterator_value (&settings),
-1,
&activation_time,
&expiration_time, &fingerprint,
NULL, &issuer, NULL);
&expiration_time,
&md5_fingerprint,
NULL, /* sha256_fingerprint */
NULL, /* subject */
&issuer,
NULL, /* serial */
NULL); /* certificate_format */

activation_time_str = certificate_iso_time (activation_time);
expiration_time_str = certificate_iso_time (expiration_time);
SENDF_TO_CLIENT_OR_FAIL
Expand All @@ -17453,11 +17487,11 @@ handle_get_settings (gmp_parser_t *gmp_parser, GError **error)
certificate_time_status (activation_time, expiration_time),
activation_time_str,
expiration_time_str,
fingerprint,
md5_fingerprint,
issuer);
g_free (activation_time_str);
g_free (expiration_time_str);
g_free (fingerprint);
g_free (md5_fingerprint);
g_free (issuer);
}

Expand Down Expand Up @@ -20216,17 +20250,25 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
{
time_t activation_time, expiration_time;
gchar *activation_time_str, *expiration_time_str;
gchar *fingerprint, *issuer;
gchar *md5_fingerprint, *issuer;

SENDF_TO_CLIENT_OR_FAIL
("<auth_conf_setting>"
"<key>cacert</key>"
"<value>%s</value>",
ldap_cacert);

get_certificate_info (ldap_cacert, -1, &activation_time,
&expiration_time, &fingerprint,
NULL, &issuer, NULL);
get_certificate_info (ldap_cacert,
-1,
&activation_time,
&expiration_time,
&md5_fingerprint,
NULL, /* sha256_fingerprint */
NULL, /* subject */
&issuer,
NULL, /* serial */
NULL); /* certificate_format */

activation_time_str = certificate_iso_time (activation_time);
expiration_time_str = certificate_iso_time (expiration_time);
SENDF_TO_CLIENT_OR_FAIL
Expand All @@ -20240,11 +20282,11 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
certificate_time_status (activation_time, expiration_time),
activation_time_str,
expiration_time_str,
fingerprint,
md5_fingerprint,
issuer);
g_free (activation_time_str);
g_free (expiration_time_str);
g_free (fingerprint);
g_free (md5_fingerprint);
g_free (issuer);

SEND_TO_CLIENT_OR_FAIL ("</auth_conf_setting>");
Expand Down
24 changes: 24 additions & 0 deletions src/gmp_get.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,30 @@ send_get_common (const char *, get_data_t *, iterator_t *,
} \
while (0)

/**
* @brief Send common part of GET response to client, returning on fail.
*
* This will work for types not using the trashcan.
*
* @param[in] type Type of resource.
* @param[in] get GET data.
* @param[in] iterator Iterator.
*/
#define SEND_GET_COMMON_NO_TRASH(type, get, iterator) \
do \
{ \
if (send_get_common (G_STRINGIFY (type), get, iterator, \
gmp_parser->client_writer, \
gmp_parser->client_writer_data, \
type##_writable (get_iterator_resource (iterator)), \
type##_in_use (get_iterator_resource (iterator)))) \
{ \
error_send_to_client (error); \
return; \
} \
} \
while (0)

int
buffer_get_filter_xml (GString *, const char *, const get_data_t *,
const char *, const char *);
Expand Down
Loading