René's URL Explorer Experiment


Title: REDIRECTION_TOKENS mutated by alias/macro create+list (4 locations) -- compounding cross-instance state corruption · Issue #1649 · python-cmd2/cmd2 · GitHub

Open Graph Title: REDIRECTION_TOKENS mutated by alias/macro create+list (4 locations) -- compounding cross-instance state corruption · Issue #1649 · python-cmd2/cmd2

X Title: REDIRECTION_TOKENS mutated by alias/macro create+list (4 locations) -- compounding cross-instance state corruption · Issue #1649 · python-cmd2/cmd2

Description: Hi cmd2 team — found a module-level state mutation bug in cmd2/cmd2.py while running adversarial test generation via tailtest. One root cause, four copy-pasted source locations, compounding effect across calls. Bug Four functions assign ...

Open Graph Description: Hi cmd2 team — found a module-level state mutation bug in cmd2/cmd2.py while running adversarial test generation via tailtest. One root cause, four copy-pasted source locations, compounding effect ...

X Description: Hi cmd2 team — found a module-level state mutation bug in cmd2/cmd2.py while running adversarial test generation via tailtest. One root cause, four copy-pasted source locations, compounding effect ...

Opengraph URL: https://github.com/python-cmd2/cmd2/issues/1649

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"REDIRECTION_TOKENS mutated by alias/macro create+list (4 locations) -- compounding cross-instance state corruption","articleBody":"Hi cmd2 team — found a module-level state mutation bug in `cmd2/cmd2.py` while running adversarial test generation via [tailtest](https://tailtest.com). One root cause, four copy-pasted source locations, compounding effect across calls.\n\n### Bug\n\nFour functions assign `constants.REDIRECTION_TOKENS` by reference then `.extend()` it with terminators:\n\n| Function | Line |\n|---|---|\n| `_alias_create` | 3821 |\n| `_alias_list` | 3901 |\n| `_macro_create` | 4068 |\n| `_macro_list` | 4191 |\n\nEach is shaped like:\n\n```python\ntokens_to_unquote = constants.REDIRECTION_TOKENS  # reference, not copy\ntokens_to_unquote.extend(self.statement_parser.terminators)\n```\n\nEvery call to these four functions permanently appends terminators to the module-level `constants.REDIRECTION_TOKENS`. Over multiple calls the list grows without bound:\n\n```\nAfter 0 calls: ['|', '\u003e', '\u003e\u003e']\nAfter 1 call:  ['|', '\u003e', '\u003e\u003e', ';']\nAfter 5 calls: ['|', '\u003e', '\u003e\u003e', ';', ';', ';', ';', ';', ';', ';', ';']\n```\n\n### Impact\n\n1. **Compounding mutation:** Each alias/macro create/list call pollutes the global list.\n2. **Cross-instance corruption:** Two `Cmd()` instances in the same process share the corrupted state. Instance A's alias operations affect instance B's redirection parsing.\n3. **Unbounded growth in long-running sessions:** Each invocation adds duplicates.\n\n### Fix\n\nIn all 4 locations, change:\n\n```python\ntokens_to_unquote = constants.REDIRECTION_TOKENS\n```\n\nto:\n\n```python\ntokens_to_unquote = list(constants.REDIRECTION_TOKENS)\n```\n\n### Reproduction\n\n```python\nimport pytest\nfrom cmd2 import Cmd\nfrom cmd2 import constants\n\n\ndef test_alias_create_does_not_mutate_redirection_tokens():\n    \"\"\"alias create should not mutate the module-level REDIRECTION_TOKENS list.\"\"\"\n    snapshot = list(constants.REDIRECTION_TOKENS)\n    app = Cmd()\n    app.onecmd_plus_hooks(\"alias create myalias echo hello\")\n    assert constants.REDIRECTION_TOKENS == snapshot, (\n        f\"BUG: REDIRECTION_TOKENS mutated by alias create. \"\n        f\"Was {snapshot!r}, now {constants.REDIRECTION_TOKENS!r}\"\n    )\n\n\ndef test_repeated_alias_creates_compound_mutation():\n    \"\"\"Compound effect: 5 alias creates should not grow REDIRECTION_TOKENS.\"\"\"\n    snapshot = list(constants.REDIRECTION_TOKENS)\n    app = Cmd()\n    for i in range(5):\n        app.onecmd_plus_hooks(f\"alias create alias_{i} echo {i}\")\n    assert constants.REDIRECTION_TOKENS == snapshot, (\n        f\"BUG: REDIRECTION_TOKENS grew over 5 alias creates: \"\n        f\"{snapshot!r} -\u003e {constants.REDIRECTION_TOKENS!r}\"\n    )\n\n\ndef test_two_instances_alias_create_independence():\n    \"\"\"Two Cmd instances should not share corrupted REDIRECTION_TOKENS state.\"\"\"\n    snapshot = list(constants.REDIRECTION_TOKENS)\n    a = Cmd()\n    b = Cmd()\n    a.onecmd_plus_hooks(\"alias create x echo x\")\n    state_after_a = list(constants.REDIRECTION_TOKENS)\n    assert state_after_a == snapshot, (\n        f\"BUG: instance A mutated module-level REDIRECTION_TOKENS: \"\n        f\"{snapshot!r} -\u003e {state_after_a!r}; instance B sees the corruption\"\n    )\n```\n\nHappy to open a PR — it's a 4-line change. Found via [tailtest](https://tailtest.com) adversarial test generation.\n","author":{"url":"https://github.com/pramodavansaber","@type":"Person","name":"pramodavansaber"},"datePublished":"2026-04-24T03:24:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1649/cmd2/issues/1649"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:a09824f1-d106-d1e5-f08b-18855a8daba4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCCE2:60C9C:47A6C:5F9DE:6A4D8BD2
html-safe-nonce02c50bc187a231f8942eec6e71c239f6cccd5efd23f9f24c262891e265120c86
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQ0UyOjYwQzlDOjQ3QTZDOjVGOURFOjZBNEQ4QkQyIiwidmlzaXRvcl9pZCI6Ijc2NDg3MDQ4NTM0NzI0MDkxNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaca0a5d3e634ff32af442eed1f3e92c3487f7d347a4174439505a937ee30e5fe3b
hovercard-subject-tagissue:4320292050
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-cmd2/cmd2/1649/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3f8ea6c5ec42ffde5ad78af7b14005c9bbd0089db9c402340617f0775096580a/python-cmd2/cmd2/issues/1649
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3f8ea6c5ec42ffde5ad78af7b14005c9bbd0089db9c402340617f0775096580a/python-cmd2/cmd2/issues/1649
og:image:altHi cmd2 team — found a module-level state mutation bug in cmd2/cmd2.py while running adversarial test generation via tailtest. One root cause, four copy-pasted source locations, compounding effect ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepramodavansaber
hostnamegithub.com
expected-hostnamegithub.com
None9f8758a3953dfe943439713a6fa4f90d542a3431f10e861ca03dd7f39009f320
turbo-cache-controlno-preview
go-importgithub.com/python-cmd2/cmd2 git https://github.com/python-cmd2/cmd2.git
octolytics-dimension-user_id17161025
octolytics-dimension-user_loginpython-cmd2
octolytics-dimension-repository_id51442999
octolytics-dimension-repository_nwopython-cmd2/cmd2
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id51442999
octolytics-dimension-repository_network_root_nwopython-cmd2/cmd2
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasebffd5484f01713a661b03469b77678f72b6574ed
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-cmd2/cmd2/issues/1649#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-cmd2%2Fcmd2%2Fissues%2F1649
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-cmd2%2Fcmd2%2Fissues%2F1649
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python-cmd2%2Fcmd2
Reloadhttps://github.com/python-cmd2/cmd2/issues/1649
Reloadhttps://github.com/python-cmd2/cmd2/issues/1649
Reloadhttps://github.com/python-cmd2/cmd2/issues/1649
Please reload this pagehttps://github.com/python-cmd2/cmd2/issues/1649
python-cmd2 https://github.com/python-cmd2
cmd2https://github.com/python-cmd2/cmd2
Notifications https://github.com/login?return_to=%2Fpython-cmd2%2Fcmd2
Fork 132 https://github.com/login?return_to=%2Fpython-cmd2%2Fcmd2
Star 689 https://github.com/login?return_to=%2Fpython-cmd2%2Fcmd2
Code https://github.com/python-cmd2/cmd2
Issues 0 https://github.com/python-cmd2/cmd2/issues
Pull requests 0 https://github.com/python-cmd2/cmd2/pulls
Discussions https://github.com/python-cmd2/cmd2/discussions
Actions https://github.com/python-cmd2/cmd2/actions
Projects https://github.com/python-cmd2/cmd2/projects
Security and quality 0 https://github.com/python-cmd2/cmd2/security
Insights https://github.com/python-cmd2/cmd2/pulse
Code https://github.com/python-cmd2/cmd2
Issues https://github.com/python-cmd2/cmd2/issues
Pull requests https://github.com/python-cmd2/cmd2/pulls
Discussions https://github.com/python-cmd2/cmd2/discussions
Actions https://github.com/python-cmd2/cmd2/actions
Projects https://github.com/python-cmd2/cmd2/projects
Security and quality https://github.com/python-cmd2/cmd2/security
Insights https://github.com/python-cmd2/cmd2/pulse
#1651https://github.com/python-cmd2/cmd2/pull/1651
REDIRECTION_TOKENS mutated by alias/macro create+list (4 locations) -- compounding cross-instance state corruptionhttps://github.com/python-cmd2/cmd2/issues/1649#top
#1651https://github.com/python-cmd2/cmd2/pull/1651
https://github.com/pramodavansaber
pramodavansaberhttps://github.com/pramodavansaber
on Apr 24, 2026https://github.com/python-cmd2/cmd2/issues/1649#issue-4320292050
tailtesthttps://tailtest.com
tailtesthttps://tailtest.com
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.