CA API Gateway - Policy DateTime Format Issue
search cancel

CA API Gateway - Policy DateTime Format Issue

book

Article ID: 193090

calendar_today

Updated On: 01-31-2024

Products

CA API Gateway API SECURITY

Issue/Introduction

Trying to validate datetime format in API Gateway to allow only specific format. Providing valid datetime range format below using set context variable..

YYYY-MM-DDTHH:mm:ss
YYYY-MM-DDTHH:mm:ssZ

We tried to validate datetime format then service throws following exception.

20200518 14:53:27.090 INFO   9680 Unable to parse date string: 2020-01-01T00:00:00

 

20200518 14:53:27.090 INFO   9680 Unable to parse date string: 2020-01-01T00:00:00Z

Would like to understand why API Gateway application is not supporting above datetime formats?

During my further testing, I have found the following anomalies

Not allowed:
YYYY-MM-DDTHH:mm:ss.S
YYYY-MM-DDTHH:mm:ssZ 
YYYY-MM-DDTHH:mm:ss
YYYY-MM-DDTHH:mmZ

Allowed:
YYYY-MM-DD HH:mm:ss.SSS  --- success
YYYY-MM-DD HH:mm:ss  --- success

Not allowed:
YYYY-MM-DDTHH:mm:ss
YYYY-MM-DDTHH:mm:ssZ

using the following payloads:
https://<HostName>/ddformat?startDate=2020-02-02&endDate=2020-02-03
https://<HostName>/ddformat?startDate=2020-02-02 00:00:00.000&endDate=2020-02-03 00:00:00.000

YYYY-MM-DD
https://<HostName>/ddformat?startDate=2020-02-02&endDate=2020-02-03
yyyy-MM-dd HH:mm:ss

https://<HostName>/ddformat?startDate=2020-02-02 00:00:00&endDate=2020-02-03 00:00:00

yyyy-MM-dd HH:mm:ss.SSS
https://<HostName>/ddformat?startDate=2020-02-02 00:00:00.000&endDate=2020-02-03 00:00:00.000

yyyy-MM-dd HH:mm:ss.SSSZ
https://<HostName>/ddformat?startDate=2020-02-02 00:00:00.000Z&endDate=2020-02-03 00:00:00.000Z

YYYY-MM-DD'T'HH:mm:ss
https://<HostName>/ddformat?startDate=2020-09-11'T'00:00:00&endDate=2020-09-11'T'00:00:00

Environment

All Supported versions of API Gateway

Cause

With format as YYYY-MM-DD HH:mm:ss.SSS

We get a failure.

Resolution

Considering the below example service:

https://localhost:8443/datetimeformat?startDate=2020-02-02 000:00:00.000&endDate=2020-02-03 000:00:00.000

Change the format to yyyy-MM-dd HH:mm:ss.SSS, and it processed it successfully.

Users should be providing yyyy in small case so YYYY and DD should be in small case as yyyy and dd.