Greenbone Vulnerability Manager
22.4.0~dev1
|
GVM management layer: Report formats. More...
#include "manage_report_formats.h"
#include "gmp_report_formats.h"
#include "manage.h"
#include "manage_sql.h"
#include "manage_sql_report_formats.h"
#include "utils.h"
#include <assert.h>
#include <errno.h>
#include <glib.h>
#include <gvm/util/fileutils.h>
#include <locale.h>
#include <stdlib.h>
#include <string.h>
Macros | |
#define | G_LOG_DOMAIN "md manage" |
GLib log domain. | |
Functions | |
gboolean | find_report_format_with_permission (const char *uuid, report_format_t *report_format, const char *permission) |
Find a report format for a specific permission, given a UUID. More... | |
int | report_format_writable (report_format_t report_format) |
Return whether a report format is writable. More... | |
int | trash_report_format_writable (report_format_t report_format) |
Return whether a trashcan report_format is writable. More... | |
const char * | report_format_param_type_name (report_format_param_type_t type) |
Get the name of a report format param type. More... | |
report_format_param_type_t | report_format_param_type_from_name (const char *name) |
Get a report format param type from a name. More... | |
static int | backup_file_name (const char *name) |
Return whether a name is a backup file name. More... | |
static int | get_report_format_files (const char *dir_name, GPtrArray **start) |
Get files associated with a report format. More... | |
int | init_report_format_file_iterator (file_iterator_t *iterator, report_format_t report_format) |
Initialise a report format file iterator. More... | |
void | cleanup_file_iterator (file_iterator_t *iterator) |
Cleanup a report type iterator. More... | |
gboolean | next_file (file_iterator_t *iterator) |
Increment a report type iterator. More... | |
const char * | file_iterator_name (file_iterator_t *iterator) |
Return the name from a file iterator. More... | |
gchar * | file_iterator_content_64 (file_iterator_t *iterator) |
Return the file contents from a file iterator. More... | |
static const gchar * | feed_dir_report_formats () |
Get path to report formats in feed. More... | |
static int | update_report_format_from_file (report_format_t report_format, const gchar *path) |
Create a report format from an XML file. More... | |
static void | create_feed_report_format_permissions (const gchar *report_format_id) |
Grant 'Feed Import Roles' access to a report format. More... | |
static int | create_report_format_from_file (const gchar *path) |
Create a report format from an XML file. More... | |
static int | should_sync_report_format_from_path (const char *path, gboolean rebuild, report_format_t *report_format) |
Gets if a report format must be synced to a file path in the feed. More... | |
static void | sync_report_format_with_feed (const gchar *path, gboolean rebuild) |
Sync a single report format with the feed. More... | |
static int | try_open_report_formats_feed_dir (GDir **dir, gboolean set_current_user) |
Open the report formats feed directory if it is available and the feed owner is set. Optionally set the current user to the feed owner on success. More... | |
int | sync_report_formats_with_feed (gboolean rebuild) |
Sync all report formats with the feed. More... | |
gboolean | report_formats_feed_dir_exists () |
Tests if the report formats feed directory exists. More... | |
void | manage_sync_report_formats () |
Sync report formats with the feed. | |
int | manage_rebuild_report_formats () |
Rebuild port lists from the feed. More... | |
gboolean | should_sync_report_formats () |
Checks if the report formats should be synced with the feed. More... | |
GVM management layer: Report formats.
Non-SQL report format code for the GVM management layer.
|
static |
Return whether a name is a backup file name.
[in] | name | Name. |
void cleanup_file_iterator | ( | file_iterator_t * | iterator | ) |
Cleanup a report type iterator.
[in] | iterator | Iterator. |
|
static |
Grant 'Feed Import Roles' access to a report format.
[in] | report_format_id | UUID of report format. |
|
static |
Create a report format from an XML file.
[in] | path | Path to report format XML. |
|
static |
Get path to report formats in feed.
gchar* file_iterator_content_64 | ( | file_iterator_t * | iterator | ) |
Return the file contents from a file iterator.
[in] | iterator | Iterator. |
const char* file_iterator_name | ( | file_iterator_t * | iterator | ) |
Return the name from a file iterator.
[in] | iterator | Iterator. |
gboolean find_report_format_with_permission | ( | const char * | uuid, |
report_format_t * | report_format, | ||
const char * | permission | ||
) |
Find a report format for a specific permission, given a UUID.
[in] | uuid | UUID of report format. |
[out] | report_format | Report format return, 0 if successfully failed to find report_format. |
[in] | permission | Permission. |
|
static |
Get files associated with a report format.
[in] | dir_name | Location of files. |
[out] | start | Files on success. |
int init_report_format_file_iterator | ( | file_iterator_t * | iterator, |
report_format_t | report_format | ||
) |
Initialise a report format file iterator.
[in] | iterator | Iterator. |
[in] | report_format | Single report format to iterate over, NULL for all. |
int manage_rebuild_report_formats | ( | ) |
Rebuild port lists from the feed.
gboolean next_file | ( | file_iterator_t * | iterator | ) |
Increment a report type iterator.
The caller must stop using this after it returns FALSE.
[in] | iterator | Task iterator. |
report_format_param_type_t report_format_param_type_from_name | ( | const char * | name | ) |
Get a report format param type from a name.
[in] | name | Param type name. |
const char* report_format_param_type_name | ( | report_format_param_type_t | type | ) |
Get the name of a report format param type.
[in] | type | Param type. |
int report_format_writable | ( | report_format_t | report_format | ) |
Return whether a report format is writable.
[in] | report_format | Report Format. |
gboolean report_formats_feed_dir_exists | ( | ) |
Tests if the report formats feed directory exists.
|
static |
Gets if a report format must be synced to a file path in the feed.
[in] | path | Path to report format XML in feed. |
[in] | rebuild | Whether ignore timestamps to force a rebuild. |
[out] | report_format | Report format id if it already exists, 0 if new. |
gboolean should_sync_report_formats | ( | ) |
Checks if the report formats should be synced with the feed.
|
static |
Sync a single report format with the feed.
[in] | path | Path to report format XML in feed. |
[in] | rebuild | Whether ignore timestamps to force a rebuild. |
int sync_report_formats_with_feed | ( | gboolean | rebuild | ) |
Sync all report formats with the feed.
Create report formats that exists in the feed but not in the db. Update report formats in the db that have changed on the feed. Do nothing to report formats in db that have been removed from the feed.
[in] | rebuild | Whether ignore timestamps to force a rebuild. |
int trash_report_format_writable | ( | report_format_t | report_format | ) |
Return whether a trashcan report_format is writable.
[in] | report_format | Report Format. |
|
static |
Open the report formats feed directory if it is available and the feed owner is set. Optionally set the current user to the feed owner on success.
The sync will be skipped if the feed directory does not exist or the feed owner is not set.
[out] | dir | The directory as GDir if available and feed owner is set, NULL otherwise. |
[in] | set_current_user | Whether to set current user to feed owner. |
|
static |
Create a report format from an XML file.
[in] | report_format | Existing report format. |
[in] | path | Full path to report format XML. |