diff --git a/src/gmp.c b/src/gmp.c
index 9311f5a16..9c85e6cd5 100644
--- a/src/gmp.c
+++ b/src/gmp.c
@@ -8026,7 +8026,8 @@ buffer_notes_xml (GString *buffer, iterator_t *notes, int include_notes_details,
if (include_notes_details == 0)
{
const char *text = note_iterator_text (notes);
- gchar *excerpt = utf8_substring (text, 0, 60);
+ gchar *excerpt = utf8_substring (text, 0,
+ setting_excerpt_size_int ());
/* This must match send_get_common. */
buffer_xml_append_printf (buffer,
"%s"
@@ -8288,7 +8289,8 @@ buffer_overrides_xml (GString *buffer, iterator_t *overrides,
if (include_overrides_details == 0)
{
const char *text = override_iterator_text (overrides);
- gchar *excerpt = utf8_substring (text, 0, 60);
+ gchar *excerpt = utf8_substring (text, 0,
+ setting_excerpt_size_int ());
/* This must match send_get_common. */
buffer_xml_append_printf (buffer,
"%s"
diff --git a/src/manage.h b/src/manage.h
index fc5819434..c917c899e 100644
--- a/src/manage.h
+++ b/src/manage.h
@@ -1167,6 +1167,13 @@ result_detection_reference (result_t, report_t, const char *, const char *,
*/
#define MIN_QOD_DEFAULT 70
+/**
+ * @brief Default size to limit note and override text to in reports.
+ */
+#define EXCERPT_SIZE_DEFAULT 300
+
+
+
void
reports_clear_count_cache_for_override (override_t, int);
@@ -3299,6 +3306,9 @@ setting_is_default_ca_cert (const gchar *);
char *
setting_filter (const char *);
+int
+setting_excerpt_size_int ();
+
void
init_setting_iterator (iterator_t *, const char *, const char *, int, int, int,
const char *);
diff --git a/src/manage_sql.c b/src/manage_sql.c
index d0466d003..d7f220061 100644
--- a/src/manage_sql.c
+++ b/src/manage_sql.c
@@ -15785,6 +15785,19 @@ check_db_settings ()
" 'Whether to rebuild report caches on changes affecting severity.',"
" '1');");
+ if (sql_int ("SELECT count(*) FROM settings"
+ " WHERE uuid = '9246a0f6-c6ad-44bc-86c2-557a527c8fb3'"
+ " AND " ACL_IS_GLOBAL () ";")
+ == 0)
+ sql ("INSERT into settings (uuid, owner, name, comment, value)"
+ " VALUES"
+ " ('9246a0f6-c6ad-44bc-86c2-557a527c8fb3', NULL,"
+ " 'Note/Override Excerpt Size',"
+ " 'The maximum length of notes and override text shown in' ||"
+ " ' reports without enabling note/override details.',"
+ " '%d');",
+ EXCERPT_SIZE_DEFAULT);
+
if (sql_int ("SELECT count(*) FROM settings"
" WHERE uuid = '" SETTING_UUID_LSC_DEB_MAINTAINER "'"
" AND " ACL_IS_GLOBAL () ";")
@@ -17148,6 +17161,13 @@ credentials_setup (credentials_t *credentials)
" ORDER BY coalesce (owner, 0) DESC LIMIT 1;",
credentials->uuid);
+ credentials->excerpt_size
+ = sql_int ("SELECT value FROM settings"
+ " WHERE name = 'Note/Override Excerpt Size'"
+ " AND " ACL_GLOBAL_OR_USER_OWNS ()
+ " ORDER BY coalesce (owner, 0) DESC LIMIT 1;",
+ credentials->uuid);
+
return 0;
}
@@ -50132,6 +50152,19 @@ setting_filter (const char *resource)
current_credentials.uuid);
}
+/**
+ * @brief Return the Note/Override Excerpt Size user setting as an int.
+ *
+ * @return The excerpt size.
+ */
+int
+setting_excerpt_size_int ()
+{
+ if (current_credentials.excerpt_size <= 0)
+ return EXCERPT_SIZE_DEFAULT;
+ return current_credentials.excerpt_size;
+}
+
/**
* @brief Return the Dynamic Severity user setting as an int.
*
@@ -50474,6 +50507,7 @@ modify_setting (const gchar *uuid, const gchar *name,
}
if (uuid && (strcmp (uuid, SETTING_UUID_ROWS_PER_PAGE) == 0
+ || strcmp (uuid, SETTING_UUID_EXCERPT_SIZE) == 0
|| strcmp (uuid, "6765549a-934e-11e3-b358-406186ea4fc5") == 0
|| strcmp (uuid, "77ec2444-e7f2-4a80-a59b-f4237782d93f") == 0
|| strcmp (uuid, "7eda49c5-096c-4bef-b1ab-d080d87300df") == 0
@@ -50586,6 +50620,12 @@ modify_setting (const gchar *uuid, const gchar *name,
reports_clear_count_cache (current_credentials.uuid);
}
+ if (strcmp (uuid, SETTING_UUID_EXCERPT_SIZE) == 0)
+ {
+ /* Note/Override Excerpt Size */
+ current_credentials.excerpt_size = atoi (value);
+ }
+
if (strcmp (uuid, "7eda49c5-096c-4bef-b1ab-d080d87300df") == 0)
{
double severity_dbl;
diff --git a/src/manage_sql.h b/src/manage_sql.h
index 11fffcd44..cfd72597d 100644
--- a/src/manage_sql.h
+++ b/src/manage_sql.h
@@ -112,6 +112,11 @@
*/
#define SETTING_UUID_MAX_ROWS_PER_PAGE "76374a7a-0569-11e6-b6da-28d24461215b"
+/**
+ * @brief UUID of 'Note/Override Excerpt Size' setting.
+ */
+#define SETTING_UUID_EXCERPT_SIZE "9246a0f6-c6ad-44bc-86c2-557a527c8fb3"
+
/**
* @brief UUID of 'Default CA Cert' setting.
*/