jfrog / charts

JFrog official Helm Charts
https://jfrog.com/integration/helm-repository/
Apache License 2.0
259 stars 448 forks source link

Audit log JSON format #1936

Closed gulecroc closed 2 weeks ago

gulecroc commented 2 weeks ago

Hello,

I would like to collect the audit log in JSON format.

I override the logback.xml file for access component :

Update the chart values :

artifactory:
  configMaps: |
    access-logback.xml: |
      <!-- PUT THE LOGBACK CONFIG-->
  copyOnEveryStartup:
    - source: /artifactory-configmaps/access-logback.xml
      target: etc/access/logback.xml
  customVolumeMounts: |
    - name: artifactory-configmaps
      mountPath: "/artifactory-configmaps"
  loggers:
    - access-security-audit-json.log

The log output :

The problem is with the field datachanged that is already in JSON format before serialization.

Do you have any solution ?

Thank you.

Guillaume

gulecroc commented 2 weeks ago

Finally I create the JSON format with the default encoder :

          <appender name="SECURITY_AUDIT_FILE_JSON" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <File>${log.dir}/access-security-audit-json.log</File>
            <encoder>
              <pattern>{"datetime":"%d{yyyy-MM-dd'T'HH:mm:ss.SSS,UTC}Z","traceid":"%formattedCustomUberTraceId","userip":"%X{audit.performingUserIp}","user":"%X{audit.performingUser}","loggedprincipal":"%X{audit.loggedinPrincipal}","entityname":"%X{audit.entityName}","eventtype":"%X{audit.securityEventType}","event":"%X{audit.securityEvent}","datachanged":%X{audit.dataChanged}}%n</pattern>
            </encoder>
            <rollingPolicy class="org.jfrog.common.logging.logback.rolling.FixedWindowWithDateRollingPolicy">
              <FileNamePattern>${log.dir.archived}/access-security-audit-json.%i.log.gz</FileNamePattern>
              <compressLatest>false</compressLatest>
            </rollingPolicy>
            <triggeringPolicy class="org.jfrog.common.logging.logback.triggering.SizeAndIntervalTriggeringPolicy">
              <MaxFileSize>25MB</MaxFileSize>
            </triggeringPolicy>
          </appender>

But I think we could have a better solution with SecurityAuditJsonLayout.