Skip to content

Commit

Permalink
Fix for not accepting the past dates as expiration for bucket lifecyc…
Browse files Browse the repository at this point in the history
…le rules

Signed-off-by: Aayush Chouhan <[email protected]>
  • Loading branch information
achouhan09 committed Dec 30, 2024
1 parent 504b3bc commit eb6f805
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/endpoint/s3/ops/s3_put_bucket_lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,16 @@ function parse_expiration(expiration) {
throw new S3Error(S3Error.InvalidArgument);
}
} else if (expiration.Date?.length === 1) {
output_expiration.date = (new Date(expiration.Date[0])).getTime();
const parsed_date = (new Date(expiration.Date[0]));
if (isNaN(parsed_date.getTime())) {
dbg.error('Invalid expiration date provided:', expiration.Date[0]);
throw new S3Error(S3Error.InvalidArgument);
}
if (parsed_date.getTime() <= Date.now()) {
dbg.error('Expiration date is in the past or current date:', expiration.Date[0], 'Parsed value:', parsed_date);
throw new S3Error(S3Error.InvalidArgument);
}
output_expiration.date = parsed_date.getTime();
} else if (expiration.ExpiredObjectDeleteMarker?.length === 1) {
output_expiration.expired_object_delete_marker = true_regex.test(expiration.ExpiredObjectDeleteMarker[0]);
}
Expand Down

0 comments on commit eb6f805

Please sign in to comment.