From 863a73363c4f81c42b14ce5395ac87908e4f8734 Mon Sep 17 00:00:00 2001 From: Robbie Bise Date: Wed, 27 Mar 2024 13:12:02 -0500 Subject: [PATCH 1/5] add some new code --- ansible/test.py | 18 ------------ docker/test.py | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 18 deletions(-) delete mode 100644 ansible/test.py create mode 100644 docker/test.py diff --git a/ansible/test.py b/ansible/test.py deleted file mode 100644 index 036464f..0000000 --- a/ansible/test.py +++ /dev/null @@ -1,18 +0,0 @@ -from Crypto.PublicKey import RSA -from Crypto.Cipher import PKCS1_OAEP - -class AsymmetricEncryption: - def __init__(self, key_size=2048): - self.key = RSA.generate(key_size) - self.private_key = self.key.export_key() - self.public_key = self.key.publickey().export_key() - - def encrypt(self, plaintext): - cipher_rsa = PKCS1_OAEP.new(self.key.publickey()) - ciphertext = cipher_rsa.encrypt(plaintext.encode()) - return ciphertext - - def decrypt(self, ciphertext): - cipher_rsa = PKCS1_OAEP.new(self.key) - plaintext = cipher_rsa.decrypt(ciphertext) - return plaintext.decode() \ No newline at end of file diff --git a/docker/test.py b/docker/test.py new file mode 100644 index 0000000..65c351d --- /dev/null +++ b/docker/test.py @@ -0,0 +1,74 @@ +import boto3 + +def process_data(data): + for item in data: + if item == 'stop': + break + elif item == 'skip': + continue + else: + print(item) + +data = ['apple', 'banana', 'skip', 'cherry', 'stop', 'date'] +process_data(data) + +class DataProcessor: + def __init__(self, data): + self.data = data + + def __iter__(self): + for item in self.data: + if item == 'stop': + break + elif item == 'skip': + continue + else: + yield item + +data = ['apple', 'banana', 'skip', 'cherry', 'stop', 'date'] +processor = DataProcessor(data) +for item in processor: + print(item) + + +class CustomObject: + def __init__(self, data): + self.data = data + + def __contains__(self, item): + return item in self.data + + def __not_contains__(self, item): + return item not in self.data + +obj = CustomObject(['apple', 'banana', 'cherry']) + +if 'apple' in obj: + print('Apple is in the object') + +if 'orange' not in obj: + print('Orange is not in the object') + + + def create_iam_policy(policy_name, policy_document): + iam_client = boto3.client('iam') + response = iam_client.create_policy( + PolicyName=policy_name, + PolicyDocument=policy_document + ) + return response['Policy']['Arn'] + + policy_name = 'UnrestrictedPolicy' + policy_document = { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": "*", + "Resource": "*" + } + ] + } + + policy_arn = create_iam_policy(policy_name, policy_document) + print(f"Created IAM policy with ARN: {policy_arn}") \ No newline at end of file From aa87ca12aa22c5b3eb8ac6c74d871a48733f6cd3 Mon Sep 17 00:00:00 2001 From: robbiebise <118204121+robbiebise@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:14:55 -0500 Subject: [PATCH 2/5] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1ca397f..45bb2bb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ node { stage('SCM') { - git 'https://github.com/robbiebise/launchpad' + git 'https://github.com/robbiebise/launchpad.git' } stage('SonarQube analysis') { def scannerHome = tool 'sonar-scanner-cli'; // must match the name of an actual scanner installation directory on your Jenkins build agent From 2cbd94f535e6d32a8bd3b52cff1c226fbfecea33 Mon Sep 17 00:00:00 2001 From: Robbie Bise Date: Wed, 27 Mar 2024 13:31:35 -0500 Subject: [PATCH 3/5] update jenkinsfile to hande pr vars --- Jenkinsfile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 45bb2bb..1ed4953 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,11 +1,15 @@ node { - stage('SCM') { - git 'https://github.com/robbiebise/launchpad.git' - } - stage('SonarQube analysis') { - def scannerHome = tool 'sonar-scanner-cli'; // must match the name of an actual scanner installation directory on your Jenkins build agent - withSonarQubeEnv('SonarQube') { - sh "${scannerHome}/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner" + stage('SCM') { + git 'https://github.com/robbiebise/launchpad' + } + stage('SonarQube analysis') { + def scannerHome = tool 'sonar-scanner-cli' + withSonarQubeEnv('SonarQube') { + if (env.CHANGE_ID) { // Check if this is a PR + sh "${scannerHome}/bin/sonar-scanner -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET}" + } else { + sh "${scannerHome}/bin/sonar-scanner" + } + } } - } } From df9d7868b3fbb1426be5ce7575ac1bbd26e59b51 Mon Sep 17 00:00:00 2001 From: Robbie Bise Date: Wed, 27 Mar 2024 13:39:33 -0500 Subject: [PATCH 4/5] fix scanner --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1ed4953..aa511ae 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ node { if (env.CHANGE_ID) { // Check if this is a PR sh "${scannerHome}/bin/sonar-scanner -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET}" } else { - sh "${scannerHome}/bin/sonar-scanner" + sh "${scannerHome}/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner" } } } From d55163fb5068f14babe5cf729306bf34dfd34a1d Mon Sep 17 00:00:00 2001 From: Robbie Bise Date: Wed, 27 Mar 2024 13:40:33 -0500 Subject: [PATCH 5/5] fix scanner --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index aa511ae..544e4ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,7 +6,7 @@ node { def scannerHome = tool 'sonar-scanner-cli' withSonarQubeEnv('SonarQube') { if (env.CHANGE_ID) { // Check if this is a PR - sh "${scannerHome}/bin/sonar-scanner -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET}" + sh "${scannerHome}/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${env.CHANGE_TARGET}" } else { sh "${scannerHome}/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner" }