search cancel

How to support STAT LIST SFTP command on CA APIM gateway


Article ID: 113408


Updated On:


STARTER PACK-7 CA Rapid App Security CA API Gateway


Case description:
CA API Gateway is acting as an SFTP server, and translating SFTP request to an HTTP call to a backend service. PUT a file was implemented, and it successfully routes via HTTP to backend services. The problem is the LIST/STAT commands which the SFTP client issues to verify the PUT has been successful. How to get the gateway to respond to these commands properly? 


Component: APIGTW


xml response for LIST/STAT are the same, here is a template, 
<?xml version="1.0" encoding="UTF-8"?> 
<file file="<true/false>" lastModified="<timestamp>" 
name="<filename>" permissions="<file permission number>" size="<filesize>"/> 

<?xml version="1.0" encoding="UTF-8"?> 
<file file="true" lastModified="1535619386000" 
name="${request.ssh.file}" permissions="664" size="666"/> 

1. file="true" for a file, file="false" for a directory 
2. on sftp client, input ls (or ls -l), it will send LIST command, input ls <file> (or ls -l <file>, or change directory, etc.), it will send STAT command 
3. for LIST command response, we can have multiple <file> elements 
4. the backend needs to provide rest API to return the properties of the uploaded file as below, 
- file type (file or directory) 
- file name (could be optional, we can get it from ${request.ssh.file}) 
- last modify timestamp 
- file permission number 
- file size 


Additional Information

The attached sample policy returns fake sftp response (it's hard coded and it's not returned from a real backend, just to show what response is accepted by what command.)
And the listen port needs to be configured to accept sftp request, here is an example,

<Please see attached file for image>

User-added image

<Please see attached file for image>

User-added image

<Please see attached file for image>

User-added image


1558695904932000113408_sktwi1f5rjvs16ic1.png get_app
1558695902913000113408_sktwi1f5rjvs16ic0.png get_app
1558695901103000113408_sktwi1f5rjvs16ibz.png get_app
1558536790282sftpLISTSTATPUTexample.xml get_app