项目作者: rewanthtammana

项目描述 :
Enhancing the security audit logging of Harbor with OpenResty
高级语言: Lua
项目地址: git://github.com/rewanthtammana/harbor-enhanced-logging.git
创建时间: 2021-07-27T09:24:03Z
项目社区:https://github.com/rewanthtammana/harbor-enhanced-logging

开源协议:

下载


Improving the security audit logging in Harbor using OpenResty

Harbor is an open-source registry that secures artifacts with policies and role-based access control, ensures images are scanned and free from vulnerabilities, and signs images as trusted. Harbor, a CNCF Graduated project, delivers compliance, performance, and interoperability to help you consistently and securely manage artifacts across cloud-native compute platforms like Kubernetes and Docker.
https://goharbor.io/

When it comes to the Security Standards and requirements of compliance Harbor doesn’t have a mechanism to perform audit logging functionality. This repo contains code to sovle this problem.

Current workflow

rewanthtammana-Harbor-default-flow.png

Enhanced workflow

rewanthtammana-Harbor-enhanced-flow.png

Installation

  • Clone Harbor repository
  • Run the install preparation script
  • Clone this repo & add the submodules
    1. git clone https://github.com/rewanthtammana/harbor-logging
    2. cd harbor-logging
    3. git submodule add https://github.com/openresty/lua-resty-redis make/common/config/nginx-custom/lua-resty-redis
  • Copy ./make/common/config/nginx-custom/ & ./make/docker-compose.yml to Harbor’s folder
  • Start & get Harbor running

Technicalities

Default logging configuration

  1. log_format timed_combined '$remote_addr - '
  2. '"$request" $status $body_bytes_sent '
  3. '"$http_referer" "$http_user_agent" '
  4. '$request_time $upstream_response_time $pipe';

Custom logging configuration

./make/common/config/nginx-custom/conf/nginx.conf contains the customized logging configuration.

Along with a bunch of other Lua codes, here, a considerable upgrade has been performed in the logging conf, here

  1. ...
  2. location / {
  3. ...
  4. default_type text/plain;
  5. access_by_lua_block {
  6. local user = require "user"
  7. local redis = require "resty.redis"
  8. local red = redis:new()
  9. ngx.var.email=user.fetch(red, ngx.var.cookie_sid)
  10. }
  11. }
  12. ...
  13. log_format timed_combined escape=none '($email) $remote_addr - '
  14. '"$request" $status $body_bytes_sent '
  15. '"$http_referer" "$http_user_agent" '
  16. '$request_time $upstream_response_time $pipe'
  17. '$request_body';

The above changes along with other replacements in architecture flows allow us to solve this problem.