models.util

Class DBLogger

lucee.Component
    extended by models.util.DBLogger

Copyright since 2016 by Ortus Solutions, Corp www.ortussolutions.com --- This is the logger for firewall actions for cbsecurity. It relies on the `firewall.logs` properties Properties - table : the table to use - schema : the schema to use (if db support it) - dsn : the dsn to use, no dsn, we use the global one - autoCreate : if true, then we will create the table. Defaults to true The columns created in the table are - id : db identifier - logDate : (created date) - action : The action the firewall took: redirect, override, block - blockType : The type of event: authentication, authorization - ip : ip address - userAgent : user agent used - userId : If a logged in user was used, their id - rule : The rule in json that triggered the event - httpMethod : The incoming HTTP Method - host : The host used in the event - path : The routed path in the event - queryString : The query string used - referer : The http referer (if any)

Class Attributes:
  • threadsafe
  •  
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
    Property Summary
    type property default serializable required
    any settings


    • access = public
    • returntype = any
    • inject = coldbox:moduleSettings:cbSecurity
    true false
    Constructor Summary
    init()
          Constructor.
    Method Summary
    boolean canLog()
         Is logging enabled or not.
    any clearAll()
         Clear all the logs by truncating the table.
    any configure()
         Configure the db logger for operation.
    numeric count()
         How many logs do we have.
    private any ensureTable()
         Verify or create the logging table.
    struct getActionsReport()
         Get the actions report.
    struct getBlockTypesReport()
         Get the block types report.
    private any getDatabaseVendor()
         Get the specifc db we are on.
    private any getDateTimeColumnType()
         Get db specific text column type.
    private string getDefaultDatasource()
         Get the default application datasource.
    query getLatest([numeric top='100'], [any action=''], [any blockType=''], [any userId=''])
         Get the top x logs from the table.
    private any getLimitEnd()
         Limit Strategy.
    private any getLimitStart()
         Limit Strategy.
    string getSettings()
    private any getTable()
         Return the table name with the appropriate schema included if found.
    private any getTextColumnType()
         Get db specific text column type.
    array getTopOffending(any column, [any top='5'])
         Get top offending report by passed column.
    any log(any action, [any blockType='AUTHENTICATION'], [any ip='[runtime expression]'], [any host='[runtime expression]'], [any httpMethod='[runtime expression]'], [any path='[runtime expression]'], [any queryString='[runtime expression]'], [any referer='[runtime expression]'], [any userAgent='[runtime expression]'], [any userId=''], [any rule='[runtime expression]'])
         Log a firewall event.
    any setSettings(any settings)
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()

    Constructor


    Property Detail

    settings

    property any settings

    Attributes:
    access - public
    required - false
    returntype - any
    inject - coldbox:moduleSettings:cbSecurity
    serializable - true

    Method Detail

    canLog

    public boolean canLog()

    Is logging enabled or not


    clearAll

    public any clearAll()

    Clear all the logs by truncating the table

    Returns:
    DBLogger

    configure

    public any configure()

    Configure the db logger for operation


    count

    public numeric count()

    How many logs do we have


    ensureTable

    private any ensureTable()

    Verify or create the logging table


    getActionsReport

    public struct getActionsReport()

    Get the actions report


    getBlockTypesReport

    public struct getBlockTypesReport()

    Get the block types report


    getDatabaseVendor

    private any getDatabaseVendor()

    Get the specifc db we are on


    getDateTimeColumnType

    private any getDateTimeColumnType()

    Get db specific text column type


    getDefaultDatasource

    private string getDefaultDatasource()

    Get the default application datasource


    getLatest

    public query getLatest([numeric top='100'], [any action=''], [any blockType=''], [any userId=''])

    Get the top x logs from the table

    Parameters:
    top - How many logs to get, defaults to 100
    action - If passed, we will filter by this action
    blockType - If passed, we will filter by this block type
    userId - If passed, we will filter by this user id

    getLimitEnd

    private any getLimitEnd()

    Limit Strategy


    getLimitStart

    private any getLimitStart()

    Limit Strategy


    getSettings

    public string getSettings()


    getTable

    private any getTable()

    Return the table name with the appropriate schema included if found.


    getTextColumnType

    private any getTextColumnType()

    Get db specific text column type


    getTopOffending

    public array getTopOffending(any column, [any top='5'])

    Get top offending report by passed column

    Parameters:
    column - The indexed column to report on
    top - The max report rows, defaults to 5

    log

    public any log(any action, [any blockType='AUTHENTICATION'], [any ip='[runtime expression]'], [any host='[runtime expression]'], [any httpMethod='[runtime expression]'], [any path='[runtime expression]'], [any queryString='[runtime expression]'], [any referer='[runtime expression]'], [any userAgent='[runtime expression]'], [any userId=''], [any rule='[runtime expression]'])

    Log a firewall event

    Parameters:
    action - The action the firewall took: redirect, override, block
    blockType - The type of event: AUTHENTICATION, AUTHORIZATION, INVALID-HOST, INVALID-IP, NON-SSL
    ip - ip address
    host - The host used in the event
    httpMethod - The incoming HTTP method
    path - The incoming path info
    queryString - The query string
    referer - The incoming referer if any
    userAgent - user agent used
    userId - If a logged in user was used, their id
    rule - The rule in json that triggered the event
    Returns:
    DBLogger

    setSettings

    public any setSettings(any settings)

    Parameters:
    settings