Skip to content

Ensure the maximum log file size is set correctly

Description

The log_rotation_size setting determines the maximum size of an individual log file. Once the maximum size is reached, automatic log file rotation will occur.

Rationale

If this is set to zero, size-triggered creation of new log files is disabled. This will prevent automatic log file rotation when files become too large, which could put log data at increased risk of loss.

Applies To

  • Databases

Tags

This rule is applied when the following tags are present:

Tag With Value
secureclouddb/provider aws
secureclouddb/service rds
secureclouddb/engine postgres

Default Rule

const { checkServerSetting, getServerSetting, isEmpty } = module

/**
 * @param {Object} databaseSettings - database settings object
 * @returns {boolean} true if the log_rotation_size greater than 0
 */

function validate(databaseSettings, parameters) {
    const settingName = 'log_rotation_size'
    const expectedValue = parameters && parameters.log_rotation_size

    var success = false;

    if (isEmpty(expectedValue)) {
      const actualValue = getServerSetting(databaseSettings, settingName) 
      success = parseInt(actualValue) > 0;
    } else {
      success = checkServerSetting(databaseSettings, settingName, expectedValue);
    } 

    return {
        success,
    }
}

// invoke
// TODO: add parameters support: organization must provide the expected size
validate(databaseSettings);