Skip to content

Commit

Permalink
oscc RT env (#111)
Browse files Browse the repository at this point in the history
Co-authored-by: sand-hya <[email protected]>
  • Loading branch information
sand-hya and sand-hya authored Oct 22, 2024
1 parent 4fc9a86 commit 1a2f84c
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 1 deletion.
39 changes: 39 additions & 0 deletions environment-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,45 @@
]
}
]
},
{
"name": "oscc-RT-env",
"version": {
"tag": "0.0.1",
"release_date": ""
},
"author": {
"name": "BeSLab",
"type": "Lab"
},
"date_of_creation": "2024-08-13T16:07:59",
"last_update_date": "2024-08-13T16:07:59",
"last_execution": {
"name": "BeSLab",
"type": "Lab",
"status": "Success",
"timestamp": "2024-08-13T16:07:59"
},
"compatible_playbooks": [
{
"name": "criticality_score",
"version": [
"0.0.1"
]
},
{
"name": "sonarqube",
"version": [
"0.0.1"
]
},
{
"name": "scorecard",
"version": [
"0.0.1"
]
}
]
}
]
}
3 changes: 2 additions & 1 deletion list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ Be-Secure/besecure-ce-env-repo/kyverno-RT-env,0.0.1
Be-Secure/besecure-ce-env-repo/TheHive-RT-env,0.0.1
Be-Secure/besecure-ce-env-repo/openpilot-RT-env,0.0.1
Be-Secure/besecure-ce-env-repo/open-adas-RT-env,0.0.1
Be-Secure/besecure-ce-env-repo/nightvision-RT-env,0.0.1
Be-Secure/besecure-ce-env-repo/nightvision-RT-env,0.0.1
Be-Secure/besecure-ce-env-repo/oscc-RT-env,0.0.1
71 changes: 71 additions & 0 deletions oscc/0.0.1/besman-oscc-RT-env-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
# If you wish to update the default configuration values, copy this file and place it under your home dir, under the same name.
# These variables are used to drive the installation of the environment script.
# The variables that start with BESMAN_ are converted to environment vars.
# If you wish to add any other vars that should be used globally, add the var using the below format.
# BESMAN_<var name>: <value>
# If you are not using any particular value, remove it or comment it(#).
#*** - These variables should not be removed, nor left empty.
# used to mention where you should clone the repo from, default value is Be-Secure
BESMAN_ORG: Be-Secure #***

# project/ml model/training dataset
BESMAN_ARTIFACT_TYPE: project #***

# Name of the artifact under assessment.
BESMAN_ARTIFACT_NAME: oscc #***

# Version of the artifact under assessment.
BESMAN_ARTIFACT_VERSION: v1.2.4 #***

# Source code url of the artifact under assessment.
BESMAN_ARTIFACT_URL: https://github.com/Be-Secure/oscc #***

# This variable stores the name of the environment file.
BESMAN_ENV_NAME: oscc-RT-env #***

# The path where you wish to clone the source code of the artifact under assessment.
# If you wish to change the clone path, provide the complete path.
BESMAN_ARTIFACT_DIR: $HOME/$BESMAN_ARTIFACT_NAME #***

# The path where we download the assessment and other required tools during installation.
BESMAN_TOOL_PATH: /opt #***

# Organization/lab/individual.
BESMAN_LAB_TYPE: Organization #***

# Name of the owner of the lab. Default is Be-Secure.
BESMAN_LAB_NAME: Be-Secure #***

# This is the local dir where we store the assessment reports. Default is home.
BESMAN_ASSESSMENT_DATASTORE_DIR: $HOME/besecure-assessment-datastore #***

# The remote repo where we store the assessment reports.
BESMAN_ASSESSMENT_DATASTORE_URL: https://github.com/Be-Secure/besecure-assessment-datastore #***

# The path where we download the ansible role of the assessment tools and other utilities
BESMAN_ANSIBLE_ROLES_PATH: $BESMAN_DIR/tmp/$BESMAN_ARTIFACT_NAME/roles #***

# The list of tools you wish to install. The tools are installed using ansible roles.
# To get the list of ansible roles run
# $ bes list --role
#add the roles here. format - <Github id>/<repo name>,<Github id>/<repo name>,<Github id>/<repo name>,... #***
BESMAN_ANSIBLE_ROLES: Be-Secure/ansible-role-oah-criticality_score,Be-Secure/ansible-role-oah-docker,Be-Secure/ansible-role-oah-sonarQube,Be-Secure/ansible-role-oah-fossology,Be-Secure/ansible-role-oah-eclipse

# sets the path of the playbook with which we run the ansible roles.
# Default path is ~/.besman/tmp/<artifact name dir>/
BESMAN_ARTIFACT_TRIGGER_PLAYBOOK_PATH: $BESMAN_DIR/tmp/$BESMAN_ARTIFACT_NAME #***

# Name of the trigger playbook which runs the ansible roles.
BESMAN_ARTIFACT_TRIGGER_PLAYBOOK: besman-$BESMAN_ARTIFACT_NAME-RT-trigger-playbook.yaml #***

# If the users likes to display all the skipped steps, set it to true.
# Default value is false
BESMAN_DISPLAY_SKIPPED_ANSIBLE_HOSTS: false #***

# The default values of the ansible roles will be present in their respective repos.
# You can go to https://github.com/Be-Secure/<repo of the ansible role>/blob/main/defaults/main.yml.
# If you wish to change the default values copy the variable from the https://github.com/Be-Secure/<repo of the ansible role>/blob/main/defaults/main.yml
# and paste it here and change the value.
# Format is <variable name>: <value>
# Eg: openjdk_version: 11
82 changes: 82 additions & 0 deletions oscc/0.0.1/besman-oscc-RT-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

function __besman_install
{

__besman_check_vcs_exist || return 1 # Checks if GitHub CLI is present or not.
__besman_check_github_id || return 1 # checks whether the user github id has been populated or not under BESMAN_USER_NAMESPACE
__besman_check_for_ansible || return 1 # Checks if ansible is installed or not.
__besman_create_roles_config_file # Creates the role config file with the parameters from env config

# Requirements file is used to list the required ansible roles. The data for requirements file comes from BESMAN_ANSIBLE_ROLES env var.
# This function updates the requirements file from BESMAN_ANSIBLE_ROLES env var.
__besman_update_requirements_file
__besman_ansible_galaxy_install_roles_from_requirements # Downloads the ansible roles mentioned in BESMAN_ANSIBLE_ROLES to BESMAN_ANSIBLE_ROLES_PATH
# This function checks for the playbook BESMAN_ARTIFACT_TRIGGER_PLAYBOOK under BESMAN_ARTIFACT_TRIGGER_PLAYBOOK_PATH.
# The trigger playbook is used to run the ansible roles.
__besman_check_for_trigger_playbook "$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK_PATH/$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK"
[[ "$?" -eq 1 ]] && __besman_create_ansible_playbook # Creates the trigger playbook if not present.
# Runs the trigger playbook. We are also passing these variables - bes_command=install; role_path=$BESMAN_ANSIBLE_ROLES_PATH
__besman_run_ansible_playbook_extra_vars "$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK_PATH/$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK" "bes_command=install role_path=$BESMAN_ANSIBLE_ROLES_PATH" || return 1
# Clones the source code repo.
if [[ -d $BESMAN_ARTIFACT_DIR ]]; then
__besman_echo_white "The clone path already contains dir names $BESMAN_ARTIFACT_NAME"
else
__besman_echo_white "Cloning source code repo from $BESMAN_USER_NAMESPACE/$BESMAN_ARTIFACT_NAME"
__besman_repo_clone "$BESMAN_USER_NAMESPACE" "$BESMAN_ARTIFACT_NAME" "$BESMAN_ARTIFACT_DIR" || return 1
cd "$BESMAN_ARTIFACT_DIR" && git checkout -b "$BESMAN_ARTIFACT_VERSION"_tavoss "$BESMAN_ARTIFACT_VERSION"
cd "$HOME"
fi

if [[ -d $BESMAN_ASSESSMENT_DATASTORE_DIR ]]
then
__besman_echo_white "Assessment datastore found at $BESMAN_ASSESSMENT_DATASTORE_DIR"
else
__besman_echo_white "Cloning assessment datastore from $\BESMAN_USER_NAMESPACE/besecure-assessment-datastore"
__besman_repo_clone "$BESMAN_USER_NAMESPACE" "besecure-assessment-datastore" "$BESMAN_ASSESSMENT_DATASTORE_DIR" || return 1

fi
# Please add the rest of the code here for installation
}

function __besman_uninstall
{
__besman_check_for_trigger_playbook "$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK_PATH/$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK"
[[ "$?" -eq 1 ]] && __besman_create_ansible_playbook
__besman_run_ansible_playbook_extra_vars "$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK_PATH/$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK" "bes_command=remove role_path=$BESMAN_ANSIBLE_ROLES_PATH" || return 1
if [[ -d $BESMAN_ARTIFACT_DIR ]]; then
__besman_echo_white "Removing $BESMAN_ARTIFACT_DIR..."
rm -rf "$BESMAN_ARTIFACT_DIR"
else
__besman_echo_yellow "Could not find dir $BESMAN_ARTIFACT_DIR"
fi
# Please add the rest of the code here for uninstallation

}

function __besman_update
{
__besman_check_for_trigger_playbook "$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK_PATH/$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK"
[[ "$?" -eq 1 ]] && __besman_create_ansible_playbook
__besman_run_ansible_playbook_extra_vars "$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK_PATH/$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK" "bes_command=update role_path=$BESMAN_ANSIBLE_ROLES_PATH" || return 1
# Please add the rest of the code here for update

}

function __besman_validate
{
__besman_check_for_trigger_playbook "$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK_PATH/$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK"
[[ "$?" -eq 1 ]] && __besman_create_ansible_playbook
__besman_run_ansible_playbook_extra_vars "$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK_PATH/$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK" "bes_command=validate role_path=$BESMAN_ANSIBLE_ROLES_PATH" || return 1
# Please add the rest of the code here for validate

}

function __besman_reset
{
__besman_check_for_trigger_playbook "$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK_PATH/$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK"
[[ "$?" -eq 1 ]] && __besman_create_ansible_playbook
__besman_run_ansible_playbook_extra_vars "$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK_PATH/$BESMAN_ARTIFACT_TRIGGER_PLAYBOOK" "bes_command=reset role_path=$BESMAN_ANSIBLE_ROLES_PATH" || return 1
# Please add the rest of the code here for reset

}

0 comments on commit 1a2f84c

Please sign in to comment.