I cannot put file with cfftp, any ideas why? - coldfusion

I am trying to create a function to upload two xml files to another website once a day, I can make a connection fine using this code
<cfftp action = "open"
username = "xxxx"
connection = "MyConnection"
password = "xxxx"
server = "xxx"
passive="yes"
secure="true">
but then when I try to put the file using this code
<cfftp
action="putFile"
connection="MyConnection"
localfile="xxx"
remotefile="xxx">
then I get this error
An error occurred during the sFTP putFile operation.
Error: Permission denied.
The error occurred in xxxxx: line 13
11 : connection="MyConnection"
12 : localfile="xxxx"
13 : remotefile="xxxx">
Additional background info is that I can upload via filezilla.

Just use passive="yes" with the putFile operation:
<cfftp
action="putFile"
connection="MyConnection"
localfile="xxx"
remotefile="xxx"
passive="yes">

I just had a look at some code I wrote a while ago that uses cfftp, and my remotefile contains the full path. Can you confirm if yours does this?
The error "permission denied" would make sense it if was trying to upload it into the wrong directory also. Let us know how you go.

Related

Custom "statusMsg" not working as expected

After adding the following adaptive authentication script, if the username is not according to the format I should be getting the custom status message saying, Access Denied, invalid username format. But instead I get the default status message, Something went wrong during the authentication process. Please try signing in again.
function onLoginRequest(context) {
executeStep(1, {
onSuccess: function(context) {
var user = context.currentKnownSubject;
if(user!= null && user.username != null && !user.username.equals('')) {
Log.info("username: " + user.username);
} else {
sendError('',{'status':'AUTHENTICATION USERNAME ERROR', 'statusMsg': 'Access denied, invalid username format.'});
}
}
});
}
In addition, I get the following error in the wso2carbon.log file as well.
TID: [-1234] [authenticationendpoint] [2022-10-05 15:44:12,715] [37951f7d-8240-48d4-ad4f-1d4c8a6a3ec4] ERROR {org.wso2.carbon.identity.application.authentication.endpoint.util.AuthContextAPIClient} - Sending GET request to URL : https://dev.wso2istemp.com/api/identity/auth/v1.1/data/AuthenticationError/0b0efc37-819d-4b39-85b2-517126c3c9cb, failed. java.io.IOException: Server returned HTTP response code: 401 for URL: https://dev.wso2istemp.com/api/identity/auth/v1.1/data/AuthenticationError/0b0efc37-819d-4b39-85b2-517126c3c9cb
...
org.wso2.carbon.identity.application.authentication.endpoint.util.AuthContextAPIClient.getContextProperties(AuthContextAPIClient.java:70)
at org.apache.jsp.retry_jsp._jspService(retry_jsp.java:194)
...
org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter.doFilter(ContentTypeBasedCachePreventionFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
...
org.wso2.carbon.identity.application.authentication.endpoint.util.filter.AuthenticationEndpointFilter.doFilter(AuthenticationEndpointFilter.java:190)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
...
The <IS_HOME>/repository/conf/deployment.toml configurations for [server] are as follows.
[server]
hostname = "dev.wso2istemp.com"
node_ip = "127.0.0.1"
base_path = "https://$ref{server.hostname}:${carbon.management.port}"
What is the reason for the following issue in the wso2carbon.log and why the custom status message is not shown properly?
When the adaptive authentication script is running, the values are passed to the Identity Server(IS) encrypted. In above case, the encrypted data chunk is passed to the IS,
https://dev.wso2istemp.com/api/identity/auth/v1.1/data/AuthenticationError/24e56d99-9494-4989-a3e2-4008b73ebd9b
with the last segment of the URL is being the data chunk. When the server tries to get that data chunk with a GET request, java.io.IOException: Server returned HTTP response code: 401 for URL which is the code for unauthorized is thrown. Since that data chunk is not properly received, the default status message is shown instead of the custom status message. The steps to resolve this are given below.
First clarify whether the dev.wso2istemp.com which you were using is not mapped with the localhost in /etc/hosts file.
Go to <IS_HOME>/repository/conf/deployment.toml file and check for the following configuration [identity.auth_framework.endpoint] and check whether the mutual SSL is set to false via mutual_ssl_manager_enabled=false
If so, enable that by commenting the mutual_ssl_manager_enabled=false, since using mutual SSL is recommended for IS. If you go to the <IS_HOME>/repository/resources/conf/default.json file, you can notice that the default value for mutual_ssl_manager_enabled is true
In a multi-node situation, the above error can occur if the mutual SSL is not enabled, If that does not resolves the issue, then you have to check whether the internal_hostname has been set properly so that the internal API calls are being sent properly.
To do that, if you have not added the following configuration to <IS_HOME>/repository/conf/deployment.toml file, you can check whether it has been properly applied to the <IS_HOME>/repository/conf/identity/identity.xml by checking for <ServerHostName>localhost</ServerHostName>
[server]
internal_hostname="localhost"
If you are using a multi-node deployment, this localhost value should be added to the SAN for the certificate when the certificate is generated (-ext SAN=dns:localhost)
keytool -genkey -alias newcert -keyalg RSA -keysize 2048 -keystore newkeystore.jks -dname "CN=dev.wso2istemp.com, OU=Is,O=Wso2,L=SL,S=WS,C=LK" -storepass mypassword -keypass mypassword -ext SAN=dns:localhost
But if you are using a single node you can add the following configuration to the deployment.toml and check whether it resolves things. (In single node case the internal_hostname should be similar to hostname)
[server]
hostname = "dev.wso2istemp.com"
internal_hostname = "dev.wso2istemp.com"
If that is not working[https://github.com/wso2/product-is/issues/11878] then go to <IS_HOME>/repository/deployment/server/webapps/authenticationendpoint/WEB-INF/web.xml and uncomment the following commented snippet.
<!--context-param>
<param-name>AuthenticationRESTEndpointURL</param-name>
<param-value>https://localhost:9443/api/identity/auth/v1.1/</param-value>
</context-param-->
This might route the internal_hostname being reflected on the request since the internal API calls are blocked when hostname of the server being replaced instead of the internal_hostname for the internal API calls(https://dev.wso2istemp.com/api/identity/auth/v1.1/data/AuthenticationError/24e56d99-9494-4989-a3e2-4008b73ebd9b).

AWS unable to get query result because of ResourceNotFoundException

I'm trying to get cloudwatch query with boto3, but I'm getting ResourceNotFoundException.
import boto3
if __name__ == "__main__":
client = boto3.client('logs')
response = client.start_query(
logGroupName='/aws/lambda/My-Stack-Name-SE349DJ',
startTime=123,
endTime=123,
queryString="fields #message",
limit=1
)
I attempted to the above code. And an error message is as follows.
botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the StartQuery operation: Log group '/aws/lambda/My-Stack-Name-SE349DJ' does not exist for account ID '11111111' (Service: AWSLogs; Status Code: 400; Error Code: ResourceNotFoundException; Request ID: xxxxx-xxxx-xxx; Proxy: null)
What I tested are as below.
The log group exists. I tested it with Logs Insights on the aws console. Also I tested after paste the log group as it is.
I added a backslash to test if '/' is a problem (ex. '/aws/lambda/My-Stack-Name-SE349DJ') and InvalidParameterException appears.
The aws account has administrate access privileges in the log group.
I got the same error message when I tested with aws cli.
An error occurred (ResourceNotFoundException) when calling the StartQuery operation: Log group 'XXXXXXXXXXXXXX' does not exist for account ID '11111111' (Service: AWSLogs; Status Code: 400; Error Code: ResourceNotFoundException; Request ID: xxxxx-xxxx-xxx; Proxy: null)
How can I solve this problem?
Actually the reason why I'm trying this is because I need to get more than 500,000 data from the filtered log group, but 10,000 are the maximum. I think It's better to pull it out by changing the start time and end time.
There is a high possibility that there are too many data in certain time, so I think it would be better to run it with boto3 rather than directly. Is there an easy way to extract more than 500,000 pieces of data from the console or other methods?
As #Marcin commented, It was because of the region configuration.
I added these lines before creating an aws client.
from botocore.config import Config
...
my_config = Config(
region_name = 'us-east-2',
)
...
client = boto3.client('logs', config=my_config)

Failed to connect to OpenTok(certificate verified failed)

I created a video chat, used Opentok like this:
in video_session_controller.rb file.
require 'opentok'
def show
#video_session = VideoSession.find_by(id: params[:id])
opentok = OpenTok::OpenTok.new ENV['OPENTOK_API_KEY'], ENV['OPENTOK_SECRET']
session = opentok.create_session :media_mode => :routed
#token = session.generate_token
#video_session.create_opentok_session(session_id: session.session_id, token: #token)
end
It is working on live site, but it is not working on local machine.
In local, it shows following error.
OpenTok::OpenTokError: Failed to connect to OpenTok. Response code:
SSL_connect returned=1 errno=0 state=error: certificate verify failed
How can I fix it?
Thanks.

Opencart Vqmod Error Writing Log

I want to ask opencart problem, I got this error:
SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data
OK
{"country_id":"100","name":"Indonesia","iso_code_2":"ID","iso_code_3":"IDN" ,"address_format":"","postcode_required":"1","zone":[{"zone_id":"1507","country_id":"100","name":"Aceh","code":"Aceh","status":" 1"},{"zone_id":"1508","country_id":"100","name":"Bali","code":"Bali","statu s":"1"},{"zone_id":"1509","country_id":"100","name":"Banten","code":"Banten ","status":"1"},{"zone_id":"1510","country_id":"100","name":"Bengkulu","cod e":"BE","status":"1"},{"zone_id":"1511","country_id":"100","name":"D.I.Yogy akarta","code":"YG","status":"1"},{"zone_id":"1512","country_id":"100","nam e":"Gorontalo","code":"GO","status":"1"},{"zone_id":"1513","country_id":"10 0","name":"Jakarta","code":"Jakarta","status":"1"},{"zone_id":"1514","count ry_id":"100","name":"Jambi","code":"JA","status":"1"},{"zone_id":"1515","co untry_id":"100","name":"Jawa Barat","code":"JB","status":"1"},{"zone_id":"1516","country_id":"100","name ":"Jawa Tengah","code":"JT","status":"1"},{"zone_id":"1517","country_id":"100","nam e":"Jawa Timur","code":"JI","status":"1"},{"zone_id":"1518","country_id":"100","name ":"Kalimantan Barat","code":"KB","status":"1"},{"zone_id":"1519","country_id":"100","name ":"Kalimantan Selatan","code":"KS","status":"1"},{"zone_id":"1520","country_id":"100","na me":"Kalimantan Tengah","code":"KT","status":"1"},{"zone_id":"1521","country_id":"100","nam e":"Kalimantan Timur","code":"KI","status":"1"},{"zone_id":"1522","country_id":"100","name ":"Kepulauan Bangka Belitung","code":"BB","status":"1"},{"zone_id":"1537","country_id":"100","n ame":"Kepulauan Riau","code":"KPR","status":"1"},{"zone_id":"1523","country_id":"100","name ":"Lampung","code":"LA","status":"1"},{"zone_id":"1524","country_id":"100", "name":"Maluku","code":"MA","status":"1"},{"zone_id":"1525","country_id":"1 00","name":"Maluku Utara","code":"MU","status":"1"},{"zone_id":"1526","country_id":"100","name ":"Nusa Tenggara Barat","code":"NB","status":"1"},{"zone_id":"1527","country_id":"100","name ":"Nusa Tenggara Timur","code":"NT","status":"1"},{"zone_id":"1528","country_id":"100","name ":"Papua","code":"PA","status":"1"},{"zone_id":"3970","country_id":"100","n ame":"Papua Barat","code":"PB","status":"1"},{"zone_id":"1529","country_id":"100","name ":"Riau","code":"RI","status":"1"},{"zone_id":"3971","country_id":"100","na me":"Sulawesi Barat","code":"SR","status":"1"},{"zone_id":"1530","country_id":"100","name ":"Sulawesi Selatan","code":"SN","status":"1"},{"zone_id":"1531","country_id":"100","na me":"Sulawesi Tengah","code":"ST","status":"1"},{"zone_id":"1532","country_id":"100","nam e":"Sulawesi Tenggara","code":"SG","status":"1"},{"zone_id":"1533","country_id":"100","n ame":"Sulawesi Utara","code":"SA","status":"1"},{"zone_id":"1534","country_id":"100","name ":"Sumatera Barat","code":"SB","status":"1"},{"zone_id":"1535","country_id":"100","name ":"Sumatera Selatan","code":"SS","status":"1"},{"zone_id":"1536","country_id":"100","na me":"Sumatera Utara","code":"SU","status":"1"}],"status":"1"}<b>Warning</b>:
file_put_contents(C:\xampp\htdocs\rumahjoy\vqmod/logs/Fri.log) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: No such file or directory in <b>/home/sloki/user/h1604/sites/rumahjoy.com/www/vqmod/vqmod.php</b> on line <b>395</b>LOG FILE COULD NOT BE WRITTEN
I have 2 question:
First, what happen with my vqmod? It got C:\xampp (localhost). I've hosted it to server which must be /home/sloki/user/.......
Second, what's wrong with JSON error? Because at localhost it works fine.
Upgrade to VQmod 2.3.2 then its solved..

'Cannot parse input stream' error when updating defects in Rally via pyral

I am using the Python Toolkit for Rally REST API to update defects on our Rally server. I have confirmed that I am able to make contact with the server and authenticate fine by getting a list of current defects. I am running into issues with updating them. I am using Python 2.7.3 with pyral 0.9.1 and requests 0.13.3.
Also, I am passing 'verify=False' to the Rally() call and have made appropriate chages to the
restapi module to compensate for this.
Here is my test code:
import sys
from pyral import Rally, rallySettings
server = "rallydev.server1.com"
user = "user#mycompany.com"
password = "trial"
workspace = "trialWorkspace"
project = "Testing Project"
defectID = "DE192"
rally = Rally(server, user, password, workspace=workspace,
project=project, verify=False)
defect_data = { "FormattedID" : defectID,
"State" : "Closed"
}
try:
defect = rally.update('Defect', defect_data)
except Exception, details:
sys.stderr.write('ERROR: %s \n' % details)
sys.exit(1)
print "Defect %s updated" % defect.FormattedID
When I run the script:
[temp]$ ./updefect.py
ERROR: Unable to update the Defect
If I change the code in the RallyRESTResponse function to print out the value of self.errors when found (line 164 of rallyresp.py), I get this output:
[temp]$ ./updefect.py
[u"Cannot parse input stream due to I/O error as JSON document: Parse error: expected '{' but saw '\uffff' [ chars read = >>>\uffff<<< ]"]
ERROR: Unable to update the Defect
I did find another question that sounds like it might possibly be related to mine here:
App SDK: Erorr parsing input stream when running query
Can you provide any assistance?
Pairing Michael's observation regarding the GZIP encoding with that of another astute Rally customer working a Support case on the issue - it appears that some versions of the requests module will default to GZIP compression if the content-type is not specifically defined.
The fix is to set content-type to application/json in the REST Headers section of pyral's config.py:
RALLY_REST_HEADERS = \
{
'X-RallyIntegrationName' : 'Python toolkit for Rally REST API',
'X-RallyIntegrationVendor' : 'Rally Software Development',
'X-RallyIntegrationVersion' : '%s.%s.%s' % __version__,
'X-RallyIntegrationLibrary' : 'pyral-%s.%s.%s' % __version__,
'X-RallyIntegrationPlatform' : 'Python %s' % platform.python_version(),
'X-RallyIntegrationOS' : platform.platform(),
'User-Agent' : 'Pyral Rally WebServices Agent',
'Content-Type' : 'application/json',
}
What you are seeing is probably not related to the Python 2.7.3 / requests 0.13.3 versions being used. The error message you saw has also been reported using the Javascript based App SDK and .NET Toolkit for Rally (2 separate reports here on SO) and at least one other person using Python 2.6.6 and requests 0.9.2. It appears that the error verbiage is being generated on the Rally WSAPI back-end. Current assessment by fellow Rally'ers is that it is an encoding related issue. The question is where the encoding issue originates.
I have yet to be able to repro this issue, having tried with several versions of Python (2.6.x and 2.7.x), several versions of requests and on Linux, MacOS and Win7.
As you seem to be pretty comfortable with diving in to the code and running in debug mode, one avenue to try is to capture the defective POST URL and POST data and attempting the update via a browser based REST client like 'Simple REST Client' or Poster and observing if you get the same error message in the WSAPI response.
I'm seeing similar behavior with pyral while trying to add an attachment to a defect.
With debugging and logging on I see this request on stdout:
2012-07-20T15:11:24.855212 PUT https://rally1.rallydev.com/slm/webservice/1.30/attachmentcontent/create.js?workspace=workspace/123456789
Then the json in the logfile:
2012-07-20 15:11:24.854 PUT attachmentcontent/create.js?workspace=workspace/123456789
{"AttachmentContent": {"Content": "iVBORw0KGgoAAAANSUhEUgAABBQAAAJrCAIAAADf2VflAAAXOWlDQ...
Then this in the logfile (after a bit of fighting with restapi.py to get around the unicode error):
2012-07-20 15:11:25.260 404 Cannot parse input stream due to I/O error as JSON document: Parse error: expected '{' but saw '?' [ chars read = >>>?<<< ]
The notable thing there is the 404 error code. Also, the "Cannot parse input stream..." error message is not coming from pyral, it's coming from Rally's server. So pyral is sending Rally something Rally can't understand.
I also logged the response headers, which may be a clue:
{'rallyrequestid': 'qs-app-03ml3akfhdpjk7c430otjv50ak.qs-app-0387404259', 'content-encoding': 'gzip', 'transfer-encoding': 'chunked', 'expires': 'Fri, 20 Jul 2012 19:18:35 GMT', 'vary': 'Accept-Encoding', 'cache-control': 'no-cache,no-store,max-age=0,must-revalidate', 'date': 'Fri, 20 Jul 2012 19:18:36 GMT', 'p3p': 'CP="NON DSP COR CURa PSAa PSDa OUR NOR BUS PUR COM NAV STA"', 'content-type': 'text/javascript; charset=utf-8'}
Note there the 'content-encoding': 'gzip'. I suspect the requests module (I'm using 0.13.3 in Macos Python 2.6) is gzip encoding its PUT request but the Rally API server is not properly decoding that.