Is it possible to use a secret/SecureString in Net...
# suitescript
w
Is it possible to use a secret/SecureString in Netsuite in the header of a https.post?
e
Yes, I think that’s the primary use case.
w
I see in the docs that the url accepts a SecureString. Can the header object contain secure strings as well?
Hmm, I think I want need to include them in clear text.
e
Yes, we use it to pass values in the Authorization header.
w
Probably not so secure
e
Correct. That would probably mean you have secrets stored in code.
w
Hmm, I want them to be stored as secrets, and I don't need to be able to “see” them in the code. But I need to add them to the http header
e
Yep, you can pull the key from the secrets store https.createSecureString(). You can pass the ID of the secret into that method. https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4418247678.html
w
Found a sample in suiteanswers that essentialy does what I want. 👍
I'll see if I can get it to work
Worked like a charm. If someone gets access to Netsuite and is able to modify the script that is allowed to use a secret, that secret can be exposed, maybe hard to restrict.
e
It’s my understanding that secrets cannot be logged within NetSuite. I think I’ve tried to log a header object after a secret has been appended and the secret was not visible in the log. But, you’re right that there’s not much you can do if someone has access to your system. They could setup a remote HTTP server and send a request to it and capture the secret that way.
b
the point of the secrets is to make it so that the script doesnt actually have access to the secret
the only time you can really see it is if the receiving server exposes it
w
Yeah, but if you can change the script then you can change the target server. (unless the secret is bound to a domain)
b
the obvious answer here being restrict the domain
w
haha, yup
just playing the devil's advocate 🙂
b
the older version of secrets used to be more restrictive and forced you to choose domains and scripts
241 Views