Giter Club home page Giter Club logo

oracle-mysql-8-stig-baseline's Introduction

Oracle MySQL 8.0 STIG Automated Compliance Validation Profile

InSpec profile to validate the secure configuration of Oracle MySQL 8.0 against DISA's Oracle MySQL 8.0 (STIG) Version 1 Release 1.

AWS-RDS-Ready: Profile updated to adapt checks when running against an AWS RDS instance of MySQL, by setting the input aws_rds to true. See Tailoring to Your Environment below.

[NOTE: The STIG guidance is based on MySQL 8 Enterprise Edition. Community Server (also used by AWS RDS) has reduced or different features. For Community Server, the MariaDB audit plugin may be used. This InSpec profile is adapted to measure accordingly when using Community Server]

Getting Started

Requirements

Oracle MySQL 8.0

  • Oracle MySQL 8.0 Database
  • Target should contain mysql cli client.

Required software on InSpec Runner

Install InSpec

Goto https://www.inspec.io/downloads/ and consult the documentation for your Operating System to download and install InSpec.

Ensure InSpec version is most recent ( > 4.23.X )

inspec --version

How to execute this instance

This profile can be executed against a remote target using the ssh transport, docker transport, or winrm transport of InSpec. Profiles can also be executed directly on the host where InSpec is installed (see https://www.inspec.io/docs/reference/cli/).

Tailoring to Your Environment

The following inputs may be configured in an inputs ".yml" file for the profile to run correctly for your specific environment. More information about InSpec inputs can be found in the InSpec Profile Documentation.

#Description: State if your database is an AWS RDS instance
#Value type: Boolean
aws_rds: false
 
#Description: privileged account username MySQL DB Server
#Value Type: string
user: (example) root

#Description: password specified user
#Value Type: string
password: (example) mysqlrootpass

#Description: hostname of MySQL DB Server
#Value Type:
host: localhost

#Description: port MySQL DB Server
#Value Type: numeric
port: 3306

#Description: Wildcard based path to list all audit log files
#Value Type: string
audit_log_path: /var/lib/mysql/audit*log*

#Description: List of documented audit admin accounts.
#Value Type: array
audit_admins: ["'root'@'localhost'", "'root'@'%'"]

#Description: Name of the documented server cert issuer.
#Value Type: string
org_appoved_cert_issuer: DoD Root CA

#Description: List of documented accounts exempted from PKI authentication.
#Value Type: array
pki_exception_users: ["healthchecker"]

#Description: List of documented accounts allowed to login with password.
#Value Type: array
authorized_password_users: ["healthchecker"]

#Description: List of documented mysql accounts with administrative privileges.# SV-235096 SV-235150 SV-235168 SV-235179
#Value Type: array
mysql_administrative_users: ["root"]

#Description: List of documented mysql administrative role grantees
#Value Type: array
mysql_administrative_grantees: ["'root'@'localhost'"]

#Description: max user connections allowed
#Value Type: numeric
max_user_connections: 50

#Description: List of approved Plugins
#Value Type: array
approved_plugins: ["audit_log"]

#Description: List of approved components
#Value Type: array
approved_components: ["file://component_validate_password"]

#Description: Authorized MySQL port definitions
#Value Type: Hash
mysql_ports:
  port: 3306
  admin_port: 33062
  mysqlx_port: 33060

#Description: Authorized MySQL socket definitions
#Value Type: Hash
mysql_sockets:
  socket: '/var/lib/mysql/mysql.sock'
  mysqlx_socket: '/var/run/mysqld/mysqlx.sock'

#Description: Location of the my.cnf file
#Value Type: string
mycnf: /etc/my.cnf

#Description: Location of the mysqld-auto.cnf file
#Value Type: string
mysqld_auto_cnf: /var/lib/mysql/auto.cnf

#Description: Location of the mysqld-auto.cnf file
#Value Type: array
authorized_procedures: []

#Description: Location of the mysqld-auto.cnf file
#Value Type: array
authorized_functions: []

#Description: Approved minimum version of MySQL
#Value Type: string
minimum_mysql_version: 8.0.25

Execute a single control in the profile

inspec exec <path to profile on runner> --input-file=<name of your inputs file>.yml --controls=SV-235096 -t <target>

Execute a single control in the profile and save results as JSON

inspec exec <path to profile on runner> --input-file=<name of your inputs file>.yml --controls=<control id> -t <target> --reporter cli json:results.json

Execute all controls in the profile

inspec exec <path to profile on runner> --input-file=<name of your inputs file>.yml -t <target>

Execute all controls in the profile and save results as JSON

inspec exec <path to profile on runner> --input-file=<name of your inputs file>.yml -t <target> --reporter cli json:results.json

Execute the profile directly on the MySQL database host

inspec exec <path to profile on the host> --input-file=<name of your inputs file>.yml --reporter cli json:results.json

oracle-mysql-8-stig-baseline's People

Contributors

ejaronne avatar hackershark avatar karikarshivani avatar raziz086 avatar ssayed118 avatar wajidraja avatar wdower avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oracle-mysql-8-stig-baseline's Issues

`Skip` statements missing

Not a requirement but to provide more meaningful output in the cli, maybe these controls can have a statement after skip:

  • SV-235095
  • SV-235098
  • SV-235102
  • SV-235105
  • SV-235106
  • SV-235107
  • SV-235108
  • SV-235109
  • SV-235110
  • SV-235111
  • SV-235112
  • SV-235113
  • SV-235114
  • SV-235115
  • SV-235116
  • SV-235117
  • SV-235118
  • SV-235119
  • SV-235120
  • SV-235121
  • SV-235122
  • SV-235123
  • SV-235124
  • SV-235125
  • SV-235126
  • SV-235127
  • SV-235128
  • SV-235129
  • SV-235130
  • SV-235131
  • SV-235132
  • SV-235133
  • SV-235140
  • SV-235141
  • SV-235142
  • SV-235147
  • SV-235149
  • SV-235151
  • SV-235152
  • SV-235153
  • SV-235156
  • SV-235157
  • SV-235163
  • SV-235164
  • SV-235165
  • SV-235166
  • SV-235170
  • SV-235171
  • SV-235172
  • SV-235173
  • SV-235174
  • SV-235175
  • SV-235176
  • SV-235177
  • SV-235178
  • SV-235182
  • SV-235183
  • SV-235184
  • SV-235185
  • SV-235195

`SV-235179` Improve failure output

Current code:

  describe 'List of users who have been delegated the right to grant permissions to other users' do
    subject { sql_session.query(query_admin_grantees).results.column('grantee') }
    it { should be_in mysql_administrative_grantees }
  end

Current output:

Screen Shot 2023-03-30 at 8 05 24 PM


Proposed code:

  all_grantees = sql_session.query(query_admin_grantees).results.rows
  unathorized_grantees = (sql_session.query(query_admin_grantees).results.column('grantee')).uniq

  describe 'Users who have been delegated the right to grant permissions to other users' do
    it "should be in the list of authorized users" do
      unathorized_grantees.each do |current_grantee|
        privileges = []
        all_grantees.each { |priv| priv.grantee == current_grantee ? privileges << priv.privilege_type : next }
        failure_message = "Unauthorized user: #{current_grantee} with privileges: #{privileges}"
        expect(current_grantee).to be_in mysql_administrative_grantees, failure_message
      end
    end
  end

Output:

Screen Shot 2023-03-30 at 8 04 47 PM

Note: Find a way to output the privileges assigned to the unauthorized users - the failure_message above isn't being displayed in the output. (Cause?)

Use `describe.one` instead of `match <regex>`

Using a describe block like this:

describe <resource> do
  it { should match /1|ON/ }
end

Returns a result that might be hard to read to some users:

Screen Shot 2023-03-09 at 2 25 26 PM

Using describe.one and splitting the tests in two would provide a cleaner result. Here are the controls currently using the match <regex> approach.

  • SV-235134
  • SV-235135
  • SV-235139
  • SV-235148
  • SV-235154
  • SV-235158
  • SV-235186
  • SV-235187
  • SV-235188
  • SV-235189
  • SV-235190

Improve base resource `mysql`

The base resource, mysql, can be enhanced to identify if the target is an AWS RDS instance. This will allow us to set AWS RDS defaults right in the resource.

Also, consider moving the logic from the local library mysql_session into the InSpec resource pack.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.