-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AWS Rekognition moderation Add-On methods #140
Conversation
WalkthroughThe recent changes focus on expanding the Uploadcare library with new capabilities, particularly around the AWS Rekognition Moderation Add-On. These updates introduce methods for detecting moderation labels in images and checking Add-On status, enhancing image processing and moderation features within the library. Changes
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
9c8a748
to
a564c59
Compare
before do | ||
allow(Uploadcare.config).to receive_message_chain(:public_key).and_return('demopublickey') | ||
allow(Uploadcare.config).to receive_message_chain(:secret_key).and_return('demosecretkey') | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been added due to changes from uploadcare/uploadcare-ruby#161
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Out of diff range and nitpick comments (14)
CHANGELOG.md (5)
Line range hint
51-51
: Consider using "Updated" instead of "Fixed" for consistency in describing non-bug changes.- * Fixed an issue with the configuration + * Updated the configuration
Line range hint
98-98
: Add periods after abbreviations like "etc." for grammatical correctness.- * Field `content_info` that includes mime-type, image (dimensions, format, etc), video information (duration, format, bitrate, etc), audio information, etc + * Field `content_info` that includes mime-type, image (dimensions, format, etc.), video information (duration, format, bitrate, etc.), audio information, etc.
Line range hint
104-104
: Remove redundancy in "API interface".- - Add Uploadcare API interface: + - Add Uploadcare API:
Line range hint
186-186
: Fix unpaired markdown link syntax.- - Tests against Ruby 2.0 and 2.1 that [had reached their EOL](https://www.ruby-lang.org/en/downloads/branches/ + - Tests against Ruby 2.0 and 2.1 that [had reached their EOL](https://www.ruby-lang.org/en/downloads/branches/)
Line range hint
84-160
: Standardize list item markers to use asterisks for consistency.- - For `Uploadcare::FileApi#get_file` + * For `Uploadcare::FileApi#get_file` - - Field `content_info` that includes mime-type, image (dimensions, format, etc), video information (duration, format, bitrate, etc), audio information, etc + * Field `content_info` that includes mime-type, image (dimensions, format, etc.), video information (duration, format, bitrate, etc.), audio information, etc. - - Field `metadata` that includes arbitrary metadata associated with a file + * Field `metadata` that includes arbitrary metadata associated with a fileREADME.md (9)
Line range hint
11-11
: Consider removing the space before the exclamation mark in "Note:" for consistency with common English punctuation practices.
Line range hint
31-31
: Replace "API interfaces" with "APIs" to avoid redundancy, as "I" in "API" already stands for "interface".- * [Uploadcare API interfaces](#uploadcare-api-interfaces) + * [Uploadcare APIs](#uploadcare-api-interfaces)
Line range hint
91-91
: Consider replacing "very important" with "crucial" to enhance the tone and avoid the overused phrase.- :warning: `require: "dotenv/rails-now"` is very important! + :warning: `require: "dotenv/rails-now"` is crucial!
Line range hint
136-136
: Add "the" before "Full list" to correct the grammatical structure of the sentence.- Full list of available options is listed in the file itself. + The full list of available options is listed in the file itself.
Line range hint
212-212
: Insert a comma after "For example" to improve the readability of the sentence.- For example you have a database table like this and model `Post`: + For example, you have a database table like this and model `Post`:
Line range hint
289-289
: Insert a comma after "caching" to correctly separate the clauses in the sentence.- If you are facing issue, with multiple input elements being rendered due to turbolinks caching you can append this fix in the `app/javascript/application.js` to overcome this: + If you are facing issue, with multiple input elements being rendered due to turbolinks caching, you can append this fix in the `app/javascript/application.js` to overcome this:
Line range hint
309-309
: Insert a comma after "Similarly" to correctly separate the introductory phrase from the main clause.- Similarly if you are using [Hotwire](https://hotwired.dev/) then use can you use below code: + Similarly, if you are using [Hotwire](https://hotwired.dev/) then use can you use below code:
Line range hint
333-333
: Replace "a" with "an" before "Uploadcare" as the following word starts with a vowel sound.- this attribute is getting wrapped with a Uploadcare object. + this attribute is getting wrapped with an Uploadcare object.
Line range hint
507-507
: Replace "an URL" with "a URL" as the pronunciation of "URL" starts with a consonant sound.- file uploading and uploading files from an URL (depending on the type of first argument - can be either String (i.e. URL) or File). + file uploading and uploading files from a URL (depending on the type of first argument - can be either String (i.e. URL) or File).
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (17)
- CHANGELOG.md (1 hunks)
- README.md (3 hunks)
- lib/uploadcare/rails/api/rest/addons_api.rb (1 hunks)
- spec/fixtures/vcr_cassettes/group_api_get_group.yml (4 hunks)
- spec/fixtures/vcr_cassettes/remove_bg.yml (1 hunks)
- spec/fixtures/vcr_cassettes/remove_bg_status.yml (1 hunks)
- spec/fixtures/vcr_cassettes/uc_clamav_virus_scan.yml (1 hunks)
- spec/fixtures/vcr_cassettes/uc_clamav_virus_scan_status.yml (1 hunks)
- spec/fixtures/vcr_cassettes/ws_rekognition_detect_labels.yml (1 hunks)
- spec/fixtures/vcr_cassettes/ws_rekognition_detect_labels_status.yml (1 hunks)
- spec/fixtures/vcr_cassettes/ws_rekognition_detect_moderation_labels.yml (1 hunks)
- spec/fixtures/vcr_cassettes/ws_rekognition_detect_moderation_labels_status.yml (1 hunks)
- spec/spec_helper.rb (2 hunks)
- spec/support/stub_config_keys.rb (1 hunks)
- spec/support/vcr.rb (1 hunks)
- spec/uploadcare/rails/api/rest/addons_api_spec.rb (1 hunks)
- spec/uploadcare/rails/api/rest/group_api_spec.rb (1 hunks)
Files skipped from review due to trivial changes (1)
- spec/support/stub_config_keys.rb
Files skipped from review as they are similar to previous changes (13)
- lib/uploadcare/rails/api/rest/addons_api.rb
- spec/fixtures/vcr_cassettes/remove_bg.yml
- spec/fixtures/vcr_cassettes/remove_bg_status.yml
- spec/fixtures/vcr_cassettes/uc_clamav_virus_scan.yml
- spec/fixtures/vcr_cassettes/uc_clamav_virus_scan_status.yml
- spec/fixtures/vcr_cassettes/ws_rekognition_detect_labels.yml
- spec/fixtures/vcr_cassettes/ws_rekognition_detect_labels_status.yml
- spec/fixtures/vcr_cassettes/ws_rekognition_detect_moderation_labels.yml
- spec/fixtures/vcr_cassettes/ws_rekognition_detect_moderation_labels_status.yml
- spec/spec_helper.rb
- spec/support/vcr.rb
- spec/uploadcare/rails/api/rest/addons_api_spec.rb
- spec/uploadcare/rails/api/rest/group_api_spec.rb
Additional Context Used
LanguageTool (29)
CHANGELOG.md (8)
Near line 9: Possible typo: you repeated a word
Context: .../spec/v2.0.0.html). ## Unreleased ### Added * Added Addons api for `AWS Rekognition Moderat...
Near line 51: Consider using a different verb for a more formal wording.
Context: ... ## 3.3.2 — 2023-03-26 ### Changed * Fixed an issue with the configuration * Updat...
Near line 98: In American English, abbreviations like “etc.” require a period.
Context: ...s mime-type, image (dimensions, format, etc), video information (duration, format, ...
Near line 98: In American English, abbreviations like “etc.” require a period.
Context: ...information (duration, format, bitrate, etc), audio information, etc - Field `met...
Near line 98: In American English, abbreviations like “etc.” require a period.
Context: ...rmat, bitrate, etc), audio information, etc - Fieldmetadata
that includes arbi...
Near line 104: This phrase is redundant (‘I’ stands for ‘interface’). Use simply “API”.
Context: ...plications ### Added - Add Uploadcare API interface: -Uploadcare::FileMetadataApi
- ...
Near line 125: This phrase is redundant (‘I’ stands for ‘interface’). Use simply “API”.
Context: ...with 1.x.* ### Added - Add Uploadcare API interface: - Uploadcare::FileApi - Uploadcare...
Near line 186: Unpaired symbol: ‘]’ seems to be missing
Context: ...d - Tests against Ruby 2.0 and 2.1 that [had reached their EOL](https://www.ruby-...README.md (21)
Near line 11: Loose punctuation mark.
Context: ...al purpose wrapper for Uploadcare API) ❗ *Note: the gem u...
Near line 31: This phrase is redundant (‘I’ stands for ‘interfaces’). Use simply “APIs”.
Context: ...(#image-transformation) * Uploadcare API interfaces * [Upl...
Near line 91: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase.
Context: ...rning:require: "dotenv/rails-now"
is very important! Run the config generator command to g...
Near line 136: Possible missing article found.
Context: ...s storing/caching, deleting files, etc. Full list of available options is listed in ...
Near line 212: After the expression ‘for example’ a comma is usually used.
Context: ...le or group to the model attribute. For example you have a database table like this and...
Near line 289: Possible missing comma found.
Context: ...ements being rendered due to turbolinks caching you can append this fix in the `app/jav...
Near line 309: A comma may be missing after the conjunctive/linking adverb ‘Similarly’.
Context: ... widget.remove(); }); }); ``` Similarly if you are using [Hotwire](https://hotw...
Near line 333: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... this attribute is getting wrapped with a Uploadcare object. This feature adds so...
Near line 353: Possible missing article found.
Context: ...picture` is an Uploadcare::Rails::File. Following methods are supported: ```ruby # Store...
Near line 397: It seems that a comma is missing.
Context: ...ar to the File but have some differences though. ```ruby # app/models/post.rb class Po...
Near line 411: Possible missing comma found.
Context: ...8-b7a6-43ff-a35f-2ebef935dc1b~1/") ``` Now thepost.attachments
is an Uploadcare...
Near line 484: This phrase is redundant (‘I’ stands for ‘interfaces’). Use simply “APIs”.
Context: ...ransformations/image/). ### Uploadcare API interfaces Uploadcare provides [APIs](https://upl...
Near line 490: Unpaired symbol: ‘[’ seems to be missing
Context: ...n RailsApp. ### Upload API [Upload Api](https://uploadcare.com/api-refs/upload-...
Near line 492: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ods to upload files in many ways. #### Upload a single file ```ruby # Load a file fi...
Near line 507: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’.
Context: ...file uploading and uploading files from an URL (depending on the type of first arg...
Near line 763: Did you mean “managing”? Or maybe you should add a pronoun? In active voice, ‘allow’ + ‘to’ takes an object, usually a pronoun.
Context: ...`` ### Webhook API WebhookApi allows to manage Uploadcare webhooks. #### Get all webh...
Near line 785: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’.
Context: ...ate a new webhook This method requires an URL that is triggered by an event, for ...
Near line 841: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’.
Context: ...onvert a document This method requires an UUID of a previously uploaded to Upload...
Near line 879: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’.
Context: ...conversion method, this method requires an UUID of a previously uploaded to Upload...
Near line 879: A comma may be missing after the conjunctive/linking adverb ‘Also’.
Context: ...previously uploaded to Uploadcare file. Also you have several options to control the...
Near line 926: Possible missing article found.
Context: ...ed file. As an example, you could store unique file identifier from your system. Metad...
#### Execute AWS Rekognition Moderation Add-On for a given target to detect moderation labels in an image. | ||
``` | ||
Note: Detected labels are stored in the file's appdata. | ||
``` | ||
|
||
```ruby | ||
Uploadcare::AddonsApi.rekognition_detect_moderation_labels('f757ea10-8b1a-4361-9a7c-56bfa5d45176') | ||
# => {"request_id"=>"dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e"} | ||
``` | ||
|
||
# Check the status of an AWS Rekognition Moderation Add-On execution request that had been started using the Execute Add-On operation. | ||
|
||
```ruby | ||
Uploadcare::AddonsApi.rekognition_detect_moderation_labels_status('dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e') | ||
# => {"status"=>"done"} | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure there is a blank line after the heading for better readability and markdown formatting.
#### Execute AWS Rekognition Moderation Add-On for a given target to detect moderation labels in an image.
+
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
#### Execute AWS Rekognition Moderation Add-On for a given target to detect moderation labels in an image. | |
``` | |
Note: Detected labels are stored in the file's appdata. | |
``` | |
```ruby | |
Uploadcare::AddonsApi.rekognition_detect_moderation_labels('f757ea10-8b1a-4361-9a7c-56bfa5d45176') | |
# => {"request_id"=>"dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e"} | |
``` | |
# Check the status of an AWS Rekognition Moderation Add-On execution request that had been started using the Execute Add-On operation. | |
```ruby | |
Uploadcare::AddonsApi.rekognition_detect_moderation_labels_status('dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e') | |
# => {"status"=>"done"} | |
``` | |
#### Execute AWS Rekognition Moderation Add-On for a given target to detect moderation labels in an image. | |
Note: Detected labels are stored in the file's appdata.
```ruby
Uploadcare::AddonsApi.rekognition_detect_moderation_labels('f757ea10-8b1a-4361-9a7c-56bfa5d45176')
# => {"request_id"=>"dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e"}
Check the status of an AWS Rekognition Moderation Add-On execution request that had been started using the Execute Add-On operation.
Uploadcare::AddonsApi.rekognition_detect_moderation_labels_status('dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e')
# => {"status"=>"done"}
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
@@ -2,13 +2,13 @@ | |||
http_interactions: | |||
- request: | |||
method: get | |||
uri: https://upload.uploadcare.com/group/info/?group_id=6053b054-b8d4-4f57-992d-94b8f1d6ba65~2&pub_key=demopublickey | |||
uri: https://upload.uploadcare.com/group/info/?group_id=6053b054-b8d4-4f57-992d-94b8f1d6ba65~2&pub_key=<uploadcare_private_key> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Sensitive data in the URI within the VCR cassette for the group_api_get_group
endpoint is not properly masked. The placeholder <uploadcare_private_key>
appears in the URI and in the user-agent string, which could potentially expose sensitive information if not handled correctly in a real environment.
spec/fixtures/vcr_cassettes/group_api_get_group.yml
:- Line containing the URI with the placeholder.
- Line containing the user-agent string with the placeholder.
Analysis chain
Ensure sensitive data is properly masked in the URI.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that sensitive data is masked in all URIs within VCR cassettes.
# Test: Search for unmasked sensitive data. Expect: No occurrences of unmasked sensitive data.
rg --type yaml --glob '*vcr_cassettes*.yml' '<uploadcare_private_key>'
Length of output: 221
Script:
#!/bin/bash
# Description: List VCR cassette files to confirm their presence and file type.
# List all files in directories containing 'vcr_cassettes' and display their file types.
find . -type f -path '*/vcr_cassettes/*' -exec file {} \;
Length of output: 1422
Script:
#!/bin/bash
# Description: List VCR cassette files to confirm their presence.
# List all files in directories containing 'vcr_cassettes' and display their paths.
find . -type f -path '*/vcr_cassettes/*'
Length of output: 2114
Script:
#!/bin/bash
# Description: Verify that sensitive data is masked in all URIs within VCR cassettes.
# Test: Search for unmasked sensitive data in the confirmed YAML files. Expect: No occurrences of unmasked sensitive data.
rg --type yaml --glob 'spec/fixtures/vcr_cassettes/*.yml' '<uploadcare_private_key>'
Length of output: 389
string: '' | ||
headers: | ||
User-Agent: | ||
- UploadcareRuby/4.0.0/5d5bb5639e3f2df33674 (Ruby/3.0.0) | ||
- UploadcareRuby/4.4.1/<uploadcare_private_key> (Ruby/3.3.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Sensitive data appears unmasked in the User-Agent headers within VCR cassettes. Immediate action is required to address this issue.
spec/fixtures/vcr_cassettes/group_api_get_group.yml
contains unmasked sensitive data in multiple lines.
Analysis chain
Ensure sensitive data is properly masked in the User-Agent header.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that sensitive data is masked in all User-Agent headers within VCR cassettes.
# Test: Search for unmasked sensitive data. Expect: No occurrences of unmasked sensitive data.
rg --type yaml --glob '*vcr_cassettes*.yml' '<uploadcare_private_key>'
Length of output: 221
Script:
#!/bin/bash
# Description: Re-verify that sensitive data is masked in all User-Agent headers within VCR cassettes by adjusting search parameters.
# Step 1: Check if there are any YAML files in the 'vcr_cassettes' directory.
echo "Checking for YAML files in 'vcr_cassettes' directory:"
fd --type f --extension yml 'vcr_cassettes'
# Step 2: If YAML files are found, re-run the search for unmasked sensitive data without the restrictive glob pattern.
echo "Searching for unmasked sensitive data in VCR cassettes:"
rg --type yaml '<uploadcare_private_key>' $(fd --type f --extension yml 'vcr_cassettes')
Length of output: 679
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. | |||
The format is based now on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | |||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). | |||
|
|||
## Unreleased | |||
|
|||
### Added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove repeated word "Added" for clarity.
- * Added Addons api for `AWS Rekognition Moderation` Add-On.
+ * Addons api for `AWS Rekognition Moderation` Add-On.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
### Added | |
### |
Description
Checklist
Summary by CodeRabbit