Skip to content

prisma_cloud.misconfiguration: Fix token expiry during pagination#17660

Merged
kcreddy merged 2 commits intoelastic:mainfrom
kcreddy:prisma_cloud-token-401
Mar 5, 2026
Merged

prisma_cloud.misconfiguration: Fix token expiry during pagination#17660
kcreddy merged 2 commits intoelastic:mainfrom
kcreddy:prisma_cloud-token-401

Conversation

@kcreddy
Copy link
Contributor

@kcreddy kcreddy commented Mar 4, 2026

Proposed commit message

prisma_cloud.misconfiguration: fix token expiry during pagination

Prisma Cloud JWT tokens expire after 10 minutes. The misconfiguration
dataset's CEL program previously skipped authentication during
pagination (want_more == true), reusing the initial token for all
subsequent page requests. When data collection took longer than
10 minutes, the token expired and API calls failed with 401.

Remove the skip-auth conditional so every invocation calls /login
before fetching data. Use state.with() to merge only changing
properties into state instead of rebuilding the full state object
in every branch, which removes the repetition of constant fields
(url, user, password, batch_size). Preserve pageToken through the
auth step so pagination continues from the correct page. Clear
next in both error paths to prevent stale pageTokens from persisting
into the next collection cycle.

Fixes #17028

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

How to test this PR locally

System tests pass successfully.

--- Test results for package: prisma_cloud - START ---
╭──────────────┬──────────────────┬───────────┬───────────┬────────┬───────────────╮
│ PACKAGE      │ DATA STREAM      │ TEST TYPE │ TEST NAME │ RESULT │  TIME ELAPSED │
├──────────────┼──────────────────┼───────────┼───────────┼────────┼───────────────┤
│ prisma_cloud │ misconfiguration │ system    │ cel       │ PASS   │ 41.821825125s │
╰──────────────┴──────────────────┴───────────┴───────────┴────────┴───────────────╯
--- Test results for package: prisma_cloud - END   ---
Done

Related issues

kcreddy added 2 commits March 4, 2026 19:35
Prisma Cloud JWT tokens expire after 10 minutes. The misconfiguration
dataset's CEL program previously skipped authentication during
pagination (want_more == true), reusing the initial token for all
subsequent page requests. When data collection took longer than
10 minutes, the token expired and API calls failed with 401.

Remove the skip-auth conditional so every invocation calls /login
before fetching data. Use state.with() to merge only changing
properties into state instead of rebuilding the full state object
in every branch, which removes the repetition of constant fields
(url, user, password, batch_size). Preserve pageToken through the
auth step so pagination continues from the correct page. Clear
next in both error paths to prevent stale pageTokens from persisting
into the next collection cycle.

Fixes elastic#17028
@kcreddy kcreddy self-assigned this Mar 4, 2026
@kcreddy kcreddy marked this pull request as ready for review March 4, 2026 14:08
@kcreddy kcreddy requested a review from a team as a code owner March 4, 2026 14:08
@andrewkroh andrewkroh added Integration:prisma_cloud Palo Alto Prisma Cloud Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] labels Mar 4, 2026
@elasticmachine
Copy link

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@kcreddy
Copy link
Contributor Author

kcreddy commented Mar 5, 2026

/test

@kcreddy kcreddy added the bugfix Pull request that fixes a bug issue label Mar 5, 2026
@kcreddy kcreddy changed the title prisma_cloud.: Fix token expiry during pagination prisma_cloud.misconfiguration: Fix token expiry during pagination Mar 5, 2026
@elastic-vault-github-plugin-prod

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@elasticmachine
Copy link

💚 Build Succeeded

cc @kcreddy

Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

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

I think we need to keep an eye on this for the impact on effort since we're getting a token for each request. If this is a problem, we can revisit and keep the token until before the TTL expires.

Also, the incident_audit has a similar pattern, but it has a TTL of 30m, so it's less likely to be a concern.

@kcreddy kcreddy merged commit 475f089 into elastic:main Mar 5, 2026
12 checks passed
@elastic-vault-github-plugin-prod

Package prisma_cloud - 4.0.2 containing this change is available at https://epr.elastic.co/package/prisma_cloud/4.0.2/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes a bug issue Integration:prisma_cloud Palo Alto Prisma Cloud Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Prisma Cloud] Misconfiguration dataset getting error 401 probably because of token expiration

4 participants