├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── action.yml ├── images ├── recommendation_example_1.png └── recommendation_example_2.png ├── s3.template.json └── s3.template.yml /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *main* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Amazon CodeGuru Reviewer for GitHub Actions 2 | 3 | Amazon CodeGuru Reviewer finds issues in your Java and Python code and provides recommendations on how to remediate them. CodeGuru Reviewer identifies 4 | 5 | 1. Code quality issues, such as deviation from best practices with AWS APIs and SDKs, concurrency issues, resource leaks, and incorrect input validation 6 | 2. [Security vulnerabilities](https://aws.amazon.com/blogs/devops/tightening-application-security-with-amazon-codeguru/), such as risks from the top [10 OWASP categories](https://owasp.org/www-project-top-ten/). 7 | 8 | Amazon CodeGuru Reviewer action can be triggered by a pull request, push, or scheduled run of your CI/CD pipeline. 9 | 10 | * Pull requests - Code quality & security recommendations for your changed lines of code are shown in the pull request. 11 | * Push - Code quality and security recommendations are shown in the security tab 12 | * Manual / Scheduled runs - Code quality and security recommendations are shown in the security tab 13 | 14 | For more information about setup, see [Create code reviews with GitHub Actions](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/working-with-cicd.html) in the *Amazon CodeGuru Reviewer User Guide*. 15 | 16 | To add CodeGuru Reviewer to your CI/CD pipeline, follow the steps under the *Usage* section. 17 | 18 | ## Usage 19 | 20 | **Step 1: Set up Your workflow.yml File** 21 | 22 | * **Add checkout to your workflow:** 23 | 24 | For CodeGuru to run, check out your repository using [actions/checkout@v2](https://github.com/actions/checkout). **You will need to set fetch-depth: 0 to fetch all history for all branches and tags.** For example: 25 | 26 | ``` 27 | - name: Checkout repository 28 | uses: actions/checkout@v2 29 | with: 30 | fetch-depth: 0 # This is a required field for CodeGuru 31 | ``` 32 | 33 | * **Provide your AWS Credentials:** 34 | 35 | We recommend following the instructions and using [aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials) to configure your credentials for a job. The IAM user or IAM role requires [AmazonCodeGuruReviewerFullAccess](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/auth-and-access-control-iam-identity-based-access-control.html#managed-full-access) policy and S3 permissions (s3:PutObject, s3:ListBucket, s3:GetObject) for the "codeguru-reviewer-*" S3 bucket. The CodeGuru Reviewer action supports credentials from GitHub hosted runners and self-hosted runners. 36 | 37 | **Step 2: Add Amazon CodeGuru Reviewer Action** 38 | 39 | The source_path is assumed to be the root of the repository (e.g. "."). 40 | 41 | Input Parameters: 42 | 43 | * s3_bucket: **Required**. When you run a CodeGuru scan, your code is first uploaded into an S3 bucket in your AWS account. Provide the name of the S3 bucket you are using. Its name must begin with a prefix of “codeguru-reviewer-”. If you haven’t created a bucket, you can create one using the bucket policy outlined in this CloudFormation template ([JSON](s3.template.json) or [YAML](s3.template.yml)) or by following these [instructions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html). Your data is always protected with CodeGuru using these [data protection practices](https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/data-protection.html). 44 | * build_path: **Optional**. In order to receive security recommendations from CodeGuru, you will need to upload your code’s build artifact to the S3 bucket. Use this optional parameter to provide the build_path of the artifact. Your build files can be .jar or .class files. 45 | * kms_key_id: **Optional**. A customer created kms key for encrypting your code. If not provided, CodeGuru Reviewer will encrypt your code using a kms key that AWS owns and manages for you. 46 | 47 | ``` 48 | - name: CodeGuru Reviewer 49 | uses: aws-actions/codeguru-reviewer@v1.1 50 | with: 51 | build_path: target # build artifact(s) directory 52 | s3_bucket: codeguru-reviewer-myactions-bucket # S3 Bucket with "codeguru-reviewer-*" prefix 53 | ``` 54 | 55 | **Step 3: Upload Results to GitHub** 56 | 57 | After your job is completed, you can view your results within the AWS Console or GitHub. To view the results in GitHub, we recommend uploading the results generated in the SARIF (Static Analysis Results Interchange Format) into GitHub using the following example codeql-action. For more details, see the upload instructions in the [GitHub documentation](https://docs.github.com/en/code-security/secure-coding/uploading-a-sarif-file-to-github#example-workflow-for-sarif-files-generated-outside-of-a-repository). 58 | 59 | ``` 60 | - name: Upload review result 61 | if: ${{ github.event_name != 'push' }} 62 | uses: github/codeql-action/upload-sarif@v1 63 | with: 64 | sarif_file: codeguru-results.sarif.json # Your results file will be named codeguru-results.sarif.json 65 | ``` 66 | 67 | Example: 68 | 69 | ``` 70 | steps: 71 | 72 | # Step 1: Checkout the repository and provide your AWS credentials 73 | - name: Checkout repository 74 | uses: actions/checkout@v2 75 | with: 76 | fetch-depth: 0 77 | 78 | - name: Configure AWS Credentials 79 | uses: aws-actions/configure-aws-credentials@v1 80 | with: 81 | aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} 82 | aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 83 | aws-region: us-west-2 # Region to access CodeGuru 84 | 85 | # Step 2: Add CodeGuru Reviewer Action 86 | - name: CodeGuru Reviewer 87 | uses: aws-actions/codeguru-reviewer@v1.1 88 | with: 89 | build_path: target # build artifact(s) directory 90 | s3_bucket: codeguru-reviewer-my-bucket # S3 Bucket with "codeguru-reviewer-*" prefix 91 | 92 | # Step 3: Upload results into GitHub 93 | - name: Upload review result 94 | if: ${{ github.event_name != 'push' }} 95 | uses: github/codeql-action/upload-sarif@v1 96 | with: 97 | sarif_file: codeguru-results.sarif.json 98 | ``` 99 | 100 | ## Recommendations 101 | 102 | After you run the CodeGuru Reviewer Action, security findings and code quality recommendations are posted on the Security tab in the GitHub UI and in the Code Reviews section of the CodeGuru Reviewer console. 103 | 104 | The following is an example of CodeGuru Reviewer recommendations for a Push or Schedule event on the Security tab in the GitHub UI. 105 | 106 | ![alt text](./images/recommendation_example_1.png) 107 | 108 | The following is an example of CodeGuru Reviewer recommendations for a Pull Request event in the Pull Request view. 109 | 110 | ![alt text](./images/recommendation_example_2.png) 111 | 112 | ## Security 113 | 114 | See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. 115 | 116 | ## License 117 | 118 | This library is licensed under the Apache-2.0 License. See the [LICENSE](LICENSE) file. 119 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'CodeGuru Reviewer' 2 | description: 'AWS CodeGuru Reviewer Action' 3 | branding: 4 | icon: 'cloud' 5 | color: 'orange' 6 | inputs: 7 | name: 8 | description: 'Repository name' 9 | default: ${{ github.repository }} 10 | required: false 11 | source_path: 12 | description: 'Path to Java source repository' 13 | default: . 14 | required: false 15 | build_path: 16 | description: 'Path to build artifact(s) - jar or class files in this directory will be uploaded for review' 17 | required: false 18 | destination_commit: 19 | description: 'SHA of next commit to be committed to source code repository after an event' 20 | default: ${{ github.event.before || github.event.pull_request.base.sha }} 21 | required: false 22 | source_commit: 23 | description: 'SHA of previous commit in the source code repository existed before an event' 24 | default: ${{ github.event.after || github.event.pull_request.head.sha }} 25 | required: false 26 | merge_base_commit: 27 | description: 'SHA of a commit thats the merge base for before and after commits in a pull or merge request' 28 | default: ${{ github.event.pull_request.merge_commit_sha }} 29 | required: false 30 | source_branch: 31 | description: 'Source branch of the event' 32 | default: ${{ github.head_ref || github.ref}} 33 | required: false 34 | destination_branch: 35 | description: 'Destination branch of the event' 36 | default: ${{ github.base_ref || github.ref }} 37 | required: false 38 | kms_key_id: 39 | description: 'AWS KMS Key ID to use for encrypting source code/build artifacts. By default, Amazon-owned encryption key is used. Supplying this value overrides it to use Customer-owned encryption key' 40 | required: false 41 | author: 42 | description: 'Author/Actor who triggered an event in the source code repository' 43 | default: ${{ github.event.actor }} 44 | required: false 45 | event_id: 46 | description: 'An identifier for the event that triggered CodeGuru Reviewer Analysis, e.g. Pull or Merge request id' 47 | default: ${{ github.event.number || github.run_number }} 48 | required: false 49 | event_name: 50 | description: 'Name of the event that triggered the CI/CD workflow [supported Events: push, pull, merge_request_event, schedule, workflow_dispatch]' 51 | default: ${{ github.event_name }} 52 | required: false 53 | event_state: 54 | description: 'State of the event that triggered the CI/CD workflow [example: pull_request: "opened"]' 55 | default: ${{ github.event.action }} 56 | required: false 57 | client_id: 58 | description: 'Unique identifier referring to a specific client version' 59 | default: GithubActions@v1 60 | required: false 61 | s3_bucket: 62 | description: 'S3 Bucket which will be used for code reviews' 63 | required: true 64 | vendor_name: 65 | description: 'Vendor Name(e.g. GITHUB, GITLAB) for CI/CD.' 66 | default: GITHUB 67 | required: false 68 | output_format: 69 | description: 'Expected format for the results (e.g SARIF, SAST, JENKINS)' 70 | default: SARIF 71 | required: false 72 | 73 | runs: 74 | using: 'docker' 75 | image: docker://public.ecr.aws/i6i1s7m3/codegurureviewer-actions-public:latest 76 | args: 77 | - --name 78 | - ${{ inputs.name }} 79 | - --source_path 80 | - ${{ inputs.source_path }} 81 | - --build_path 82 | - ${{ inputs.build_path }} 83 | - --destination_branch 84 | - ${{ inputs.destination_branch }} 85 | - --before_commit_sha 86 | - ${{ inputs.destination_commit }} 87 | - --source_branch 88 | - ${{ inputs.source_branch }} 89 | - --after_commit_sha 90 | - ${{ inputs.source_commit }} 91 | - --kms_key_id 92 | - ${{ inputs.kms_key_id }} 93 | - --agent 94 | - ${{ inputs.author }} 95 | - --merge_commit_sha 96 | - ${{ inputs.merge_base_commit }} 97 | - --event_id 98 | - ${{ inputs.event_id }} 99 | - --event_name 100 | - ${{ inputs.event_name }} 101 | - --event_state 102 | - ${{ inputs.event_state }} 103 | - --client_id 104 | - ${{ inputs.client_id }} 105 | - --s3_bucket 106 | - ${{ inputs.s3_bucket }} 107 | - --vendor_name 108 | - ${{ inputs.vendor_name }} 109 | - --output_format 110 | - ${{ inputs.output_format }} 111 | -------------------------------------------------------------------------------- /images/recommendation_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-actions/codeguru-reviewer/be84fd2e1140159061a7a387ffd1d404ed8f75a1/images/recommendation_example_1.png -------------------------------------------------------------------------------- /images/recommendation_example_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-actions/codeguru-reviewer/be84fd2e1140159061a7a387ffd1d404ed8f75a1/images/recommendation_example_2.png -------------------------------------------------------------------------------- /s3.template.json: -------------------------------------------------------------------------------- 1 | { 2 | "AWSTemplateFormatVersion": "2010-09-09", 3 | "Resources": { 4 | "CodeGuruReviewerBucket": { 5 | "Type": "AWS::S3::Bucket", 6 | "Properties": { 7 | "BucketName": "codeguru-reviewer-my-bucket", 8 | "BucketEncryption": { 9 | "ServerSideEncryptionConfiguration": [ 10 | { 11 | "ServerSideEncryptionByDefault": { 12 | "SSEAlgorithm": "AES256" 13 | } 14 | } 15 | ] 16 | } 17 | } 18 | }, 19 | "CodeGuruReviewerCICDActionsBucketPolicy": { 20 | "Type": "AWS::S3::BucketPolicy", 21 | "Properties": { 22 | "PolicyDocument": { 23 | "Id": "S3BucketPolicy", 24 | "Version": "2012-10-17", 25 | "Statement": [ 26 | { 27 | "Sid": "DenyPublicReadACL", 28 | "Effect": "Deny", 29 | "Principal": { 30 | "AWS": "*" 31 | }, 32 | "Action": [ 33 | "s3:PutObject", 34 | "s3:PutObjectAcl" 35 | ], 36 | "Resource": [ 37 | { 38 | "Fn::Sub": "${CodeGuruReviewerBucket.Arn}" 39 | }, 40 | { 41 | "Fn::Sub": "${CodeGuruReviewerBucket.Arn}/*" 42 | } 43 | ], 44 | "Condition": { 45 | "StringEquals": { 46 | "s3:x-amz-acl": [ 47 | "public-read", 48 | "public-read-write", 49 | "authenticated-read" 50 | ] 51 | } 52 | } 53 | }, 54 | { 55 | "Sid": "DenyPublicReadGrant", 56 | "Effect": "Deny", 57 | "Principal": { 58 | "AWS": "*" 59 | }, 60 | "Action": [ 61 | "s3:PutObject", 62 | "s3:PutObjectAcl" 63 | ], 64 | "Resource": [ 65 | { 66 | "Fn::Sub": "${CodeGuruReviewerBucket.Arn}" 67 | }, 68 | { 69 | "Fn::Sub": "${CodeGuruReviewerBucket.Arn}/*" 70 | } 71 | ], 72 | "Condition": { 73 | "StringEquals": { 74 | "s3:x-amz-grant-read": [ 75 | "*http://acs.amazonaws.com/groups/global/AllUsers*", 76 | "*http://acs.amazonaws.com/groups/global/AuthenticatedUsers*" 77 | ] 78 | } 79 | } 80 | }, 81 | { 82 | "Sid": "DenyPublicListACL", 83 | "Effect": "Deny", 84 | "Principal": { 85 | "AWS": "*" 86 | }, 87 | "Action": "s3:PutBucketAcl", 88 | "Resource": [ 89 | { 90 | "Fn::Sub": "${CodeGuruReviewerBucket.Arn}" 91 | }, 92 | { 93 | "Fn::Sub": "${CodeGuruReviewerBucket.Arn}/*" 94 | } 95 | ], 96 | "Condition": { 97 | "StringEquals": { 98 | "s3:x-amz-acl": [ 99 | "public-read", 100 | "public-read-write", 101 | "authenticated-read" 102 | ] 103 | } 104 | } 105 | }, 106 | { 107 | "Sid": "DenyPublicListGrant", 108 | "Effect": "Deny", 109 | "Principal": { 110 | "AWS": "*" 111 | }, 112 | "Action": "s3:PutBucketAcl", 113 | "Resource": [ 114 | { 115 | "Fn::Sub": "${CodeGuruReviewerBucket.Arn}" 116 | }, 117 | { 118 | "Fn::Sub": "${CodeGuruReviewerBucket.Arn}/*" 119 | } 120 | ], 121 | "Condition": { 122 | "StringEquals": { 123 | "s3:x-amz-grant-read": [ 124 | "*http://acs.amazonaws.com/groups/global/AllUsers*", 125 | "*http://acs.amazonaws.com/groups/global/AuthenticatedUsers*" 126 | ] 127 | } 128 | } 129 | }, 130 | { 131 | "Sid": "DenyInSecureRequest", 132 | "Effect": "Deny", 133 | "Principal": "*", 134 | "Action": "s3:*", 135 | "Resource": [ 136 | { 137 | "Fn::Sub": "${CodeGuruReviewerBucket.Arn}" 138 | }, 139 | { 140 | "Fn::Sub": "${CodeGuruReviewerBucket.Arn}/*" 141 | } 142 | ], 143 | "Condition": { 144 | "Bool": { 145 | "aws:SecureTransport": "false" 146 | } 147 | } 148 | }, 149 | { 150 | "Sid": "AllowS3WriteAccess", 151 | "Effect": "Allow", 152 | "Principal": { 153 | "AWS": "arn:aws:iam:::root" 154 | }, 155 | "Action": "s3:PutObject", 156 | "Resource": [ 157 | { 158 | "Fn::Sub": "${CodeGuruReviewerBucket.Arn}/*" 159 | } 160 | ] 161 | }, 162 | { 163 | "Sid": "DenyS3ReadAccess", 164 | "Effect": "Deny", 165 | "Principal": "*", 166 | "Action": "s3:GetObject", 167 | "Resource": [ 168 | { 169 | "Fn::Sub": "${CodeGuruReviewerBucket.Arn}/*" 170 | } 171 | ], 172 | "Condition": { 173 | "StringNotLike": { 174 | "aws:PrincipalArn": "arn:aws:iam:::role/aws-service-role/codeguru-reviewer.amazonaws.com/AWSServiceRoleForAmazonCodeGuruReviewer" 175 | } 176 | } 177 | } 178 | ] 179 | }, 180 | "Bucket": { 181 | "Ref": "CodeGuruReviewerBucket" 182 | } 183 | } 184 | } 185 | } 186 | } -------------------------------------------------------------------------------- /s3.template.yml: -------------------------------------------------------------------------------- 1 | --- 2 | AWSTemplateFormatVersion: '2010-09-09' 3 | Resources: 4 | CodeGuruReviewerBucket: 5 | Type: AWS::S3::Bucket 6 | Properties: 7 | BucketName: codeguru-reviewer-my-bucket 8 | BucketEncryption: 9 | ServerSideEncryptionConfiguration: 10 | - ServerSideEncryptionByDefault: 11 | SSEAlgorithm: AES256 12 | 13 | CodeGuruReviewerCICDActionsBucketPolicy: 14 | Type: AWS::S3::BucketPolicy 15 | Properties: 16 | PolicyDocument: 17 | Id: S3BucketPolicy 18 | Version: '2012-10-17' 19 | Statement: 20 | - Sid: DenyPublicReadACL 21 | Effect: Deny 22 | Principal: 23 | AWS: "*" 24 | Action: 25 | - s3:PutObject 26 | - s3:PutObjectAcl 27 | Resource: 28 | - Fn::Sub: "${CodeGuruReviewerBucket.Arn}" 29 | - Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*" 30 | Condition: 31 | StringEquals: 32 | s3:x-amz-acl: 33 | - public-read 34 | - public-read-write 35 | - authenticated-read 36 | - Sid: DenyPublicReadGrant 37 | Effect: Deny 38 | Principal: 39 | AWS: "*" 40 | Action: 41 | - s3:PutObject 42 | - s3:PutObjectAcl 43 | Resource: 44 | - Fn::Sub: "${CodeGuruReviewerBucket.Arn}" 45 | - Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*" 46 | Condition: 47 | StringEquals: 48 | s3:x-amz-grant-read: 49 | - "*http://acs.amazonaws.com/groups/global/AllUsers*" 50 | - "*http://acs.amazonaws.com/groups/global/AuthenticatedUsers*" 51 | - Sid: DenyPublicListACL 52 | Effect: Deny 53 | Principal: 54 | AWS: "*" 55 | Action: s3:PutBucketAcl 56 | Resource: 57 | - Fn::Sub: "${CodeGuruReviewerBucket.Arn}" 58 | - Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*" 59 | Condition: 60 | StringEquals: 61 | s3:x-amz-acl: 62 | - public-read 63 | - public-read-write 64 | - authenticated-read 65 | - Sid: DenyPublicListGrant 66 | Effect: Deny 67 | Principal: 68 | AWS: "*" 69 | Action: s3:PutBucketAcl 70 | Resource: 71 | - Fn::Sub: "${CodeGuruReviewerBucket.Arn}" 72 | - Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*" 73 | Condition: 74 | StringEquals: 75 | s3:x-amz-grant-read: 76 | - "*http://acs.amazonaws.com/groups/global/AllUsers*" 77 | - "*http://acs.amazonaws.com/groups/global/AuthenticatedUsers*" 78 | - Sid: DenyInSecureRequest 79 | Effect: Deny 80 | Principal: "*" 81 | Action: s3:* 82 | Resource: 83 | - Fn::Sub: "${CodeGuruReviewerBucket.Arn}" 84 | - Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*" 85 | Condition: 86 | Bool: 87 | aws:SecureTransport: 'false' 88 | - Sid: AllowS3WriteAccess 89 | Effect: Allow 90 | Principal: 91 | AWS: arn:aws:iam:::root 92 | Action: s3:PutObject 93 | Resource: 94 | - Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*" 95 | - Sid: DenyS3ReadAccess 96 | Effect: Deny 97 | Principal: "*" 98 | Action: s3:GetObject 99 | Resource: 100 | - Fn::Sub: "${CodeGuruReviewerBucket.Arn}/*" 101 | Condition: 102 | StringNotLike: 103 | aws:PrincipalArn: arn:aws:iam:::role/aws-service-role/codeguru-reviewer.amazonaws.com/AWSServiceRoleForAmazonCodeGuruReviewer 104 | Bucket: 105 | Ref: CodeGuruReviewerBucket --------------------------------------------------------------------------------