diff --git a/Jenkinsfile b/Jenkinsfile index 1ca397f..544e4ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,11 +1,15 @@ node { - stage('SCM') { - git 'https://github.com/robbiebise/launchpad' - } - 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}/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" + } + } } - } } 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