Skip to content

Create Sample4.java#5

Open
djiten-dev wants to merge 1 commit intomasterfrom
dev
Open

Create Sample4.java#5
djiten-dev wants to merge 1 commit intomasterfrom
dev

Conversation

@djiten-dev
Copy link
Owner

No description provided.

}

private AmazonS3 getAmazonS3Client() {
AWSCredentials awsCredentials = new BasicAWSCredentials(accessKeyId, secretAccessKey);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

If possible, use temporary security credentials (IAM roles) instead of long-term access keys.
Long-term access keys, such as those associated with IAM users and AWS account root users, remain valid until you manually revoke them. However, temporary security credentials obtained through IAM roles and other features of the AWS Security Token Service expire after a short period of time. Use temporary security credentials to help reduce your risk in case credentials are accidentally exposed.
Learn more about best practices for managing AWS access keys.

public List<Customer> piiData(DataSource ds) {
List<Customer> customers = new ArrayList<Customer>();
try {
Connection connection = ds.getConnection();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the following resource: connection. Currently, there are execution paths that do not contain closure statements. Either a) close connection in a try-finally block or b) close the resource by declaring connection in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

try {
Connection connection = ds.getConnection();
String sql="select name, address, ssn, phoneNumber, password from customer";
ResultSet rs= connection.createStatement().executeQuery(sql);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the following resource: rs. Currently, there are execution paths that do not contain closure statements. Either a) close rs in a try-finally block or b) close the resource by declaring rs in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

public Map<String, String> sqlInjection(DataSource ds, HttpServletRequest request) {
Map<String, String> nameValueMAp = new HashMap<String, String>();
try {
Connection connection = ds.getConnection();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the following resource: connection. Currently, there are execution paths that do not contain closure statements. Either a) close connection in a try-finally block or b) close the resource by declaring connection in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

try {
Connection connection = ds.getConnection();
String sql="select name, title from employee where empId="+request.getParameter("empID");
ResultSet rs= connection.createStatement().executeQuery(sql);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the following resource: rs. Currently, there are execution paths that do not contain closure statements. Either a) close rs in a try-finally block or b) close the resource by declaring rs in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant