Skip to content

Conversation

@tejaswiMinnu
Copy link
Contributor

@tejaswiMinnu tejaswiMinnu commented Dec 1, 2025

This reverts commit a73dd47.

When defining the response model for an ARM PUT or GET operation, any property that contains sensitive information (such as passwords, keys, tokens, credentials, or other secrets) must include the "x-ms-secret": true annotation. This ensures that secrets are properly identified and handled according to ARM security guidelines.

The last commit changes were based on suggestions from the typespec team. You can review the typespec PR here: Azure/typespec-azure#3411.

  • Added checks for keywords ending with sensitive secrets.
  • Exclude key when used in a model that only has 1 other property value(Get rid of most key instance as its just key value pair)

rules: XMSSecretInResponse

…r properties containing secrets for PUT/GET responses (#800)" (#801)

This reverts commit a73dd47.
@AkhilaIlla
Copy link
Collaborator

Copy link
Collaborator

@AkhilaIlla AkhilaIlla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test the new rule using staging linter workflow and validate if works as expected.

@AkhilaIlla
Copy link
Collaborator

@tejaswiMinnu you should be able to follow- https://github.com/Azure/azure-openapi-validator/blob/main/.github/workflows/README-staging-lint-checks.md and test the new rule.

currently its a NoOp as the rule name isnt mentioned in the body or as label-https://github.com/Azure/azure-openapi-validator/actions/runs/19814210448/job/56762071187?pr=805

@tejaswiMinnu
Copy link
Contributor Author

I reviewed the staging lintdiff pipeline results.

Before adding the typespec logic, there were 180 errors, some of which were false positives.
https://github.com/Azure/azure-openapi-validator/actions/runs/19839433846
INFO | Runner | summary | Files scanned: 100, Errors: 180, Warnings: 0

After implementing the typespec logic, the errors reduced to 72, and I checked, there are no false positives now.https://github.com/Azure/azure-openapi-validator/actions/runs/19903790744
INFO | Runner | summary | Files scanned: 100, Errors: 72, Warnings: 0

function isPotentialSensitiveProperty(propertyName: string): boolean {
const lowerName = propertyName.toLowerCase()
return (
sensitiveKeywords.some((keyword) => lowerName.endsWith(keyword) && !lowerName.startsWith(keyword)) &&
Copy link
Collaborator

@AkhilaIlla AkhilaIlla Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lowerName.endsWith(keyword) && !lowerName.startsWith(keyword)

why endwith & not equals? #Resolved

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm

@@ -0,0 +1,52 @@
const sensitiveKeywords = ["access", "credential", "secret", "password", "key", "token", "auth", "connection"]

const excludeKeywords = ["publicKey"].map((keyword) => keyword.toLowerCase())
Copy link
Collaborator

@AkhilaIlla AkhilaIlla Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.map((keyword) => keyword.toLowerCase())

why map to convert to lowercase and not what you ahev for sensitive keywords? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to exclude "publicKey" since it is not a secret as suggested by typespec.
To explicitly keep it as "publicKey" for clarity, and this is how it is typically defined in .ts or .json files.

isPotentialSensitiveProperty(prpName) && // property name matches sensitive keywords
properties[prpName] && // property exists
properties[prpName]["x-ms-secret"] !== true && // not explicitly marked as secret
!keyValuePairCheck && // not a key-value pair key
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!keyValuePairCheck && // not a key-value pair key

what is this additional check for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion from typespec team: "Exclude key when used in a model that only has 1 other property value(Get rid of most key instance as its just key value pair)"

Without this check, we were getting a bunch of false positives. That’s why the typespec team came up with all these new checks, and now they’ve added them to their code too to avoid false positives.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and why is this- Exclude key when used in a model that only has 1 other property value(Get rid of most key instance as its just key value pair)?

function isPotentialSensitiveProperty(propertyName: string): boolean {
const lowerName = propertyName.toLowerCase()
return (
sensitiveKeywords.some((keyword) => lowerName.endsWith(keyword) && !lowerName.startsWith(keyword)) &&
Copy link
Collaborator

@AkhilaIlla AkhilaIlla Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!lowerName.startsWith(keyword)

is it ok to start with these keywords?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, same here—the typespec team introduced some new checks to cut down on all those false positives.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, passwordXYZ is fine to be defined?

})
})

test("XMSSecretInResponse should find no errors with newly added typespec conditions", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with newly added typespec conditions

what does this mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the last commit, all checks were sourced from the typespec team. I have added a few additional tests to verify if they align with the new checks.
here is the PR - Azure/typespec-azure#3411

},
token: {
type: "string",
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this not flagged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be flagged according to the new checks from typespec. "somethingtoken" should fail, but just "token" should not. Some JSONs have fields like tokenName, tokenURL, and tokenValue; these should not be flagged since they are only names and URLs, not secrets.
However, fields such as Resourcetoken, resourceaccess, resourceauth, and resourceconnection are actual secrets and should be flagged.

Copy link

@raosuhas raosuhas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@tejaswiMinnu tejaswiMinnu merged commit f299af5 into main Dec 16, 2025
8 checks passed
@tejaswiMinnu tejaswiMinnu deleted the rerevert-pr-800 branch December 16, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants