René's URL Explorer Experiment


Title: False Negative: Guards in while loop with break fail to 'control' variable usage outside · Issue #8490 · github/codeql · GitHub

Open Graph Title: False Negative: Guards in while loop with break fail to 'control' variable usage outside · Issue #8490 · github/codeql

X Title: False Negative: Guards in while loop with break fail to 'control' variable usage outside · Issue #8490 · github/codeql

Description: Take the following two examples: static File safe11() throws IOException { File temp = null; if (temp == null) { while (true) { temp = File.createTempFile("test", "directory"); if (temp.delete() && temp.mkdir()) { break; } } } return tem...

Open Graph Description: Take the following two examples: static File safe11() throws IOException { File temp = null; if (temp == null) { while (true) { temp = File.createTempFile("test", "directory"); if (temp.delete() &&...

X Description: Take the following two examples: static File safe11() throws IOException { File temp = null; if (temp == null) { while (true) { temp = File.createTempFile("test", "directory"); ...

Opengraph URL: https://github.com/github/codeql/issues/8490

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"False Negative: Guards in while loop with break fail to 'control' variable usage outside","articleBody":"Take the following two examples:\r\n\r\n```java\r\nstatic File safe11() throws IOException {\r\n    File temp = null;\r\n    if (temp == null) {\r\n        while (true) {\r\n            temp = File.createTempFile(\"test\", \"directory\");\r\n            if (temp.delete() \u0026\u0026 temp.mkdir()) {\r\n                break;\r\n            }\r\n        }\r\n    }\r\n    return temp;\r\n}\r\n\r\nFile safe12temp;\r\nFile safe12() throws IOException {\r\n    if (safe12temp == null) {\r\n        while (true) {\r\n            safe12temp = File.createTempFile(\"test\", \"directory\");\r\n            if (safe12temp.delete() \u0026\u0026 safe12temp.mkdir()) {\r\n                break;\r\n            }\r\n        }\r\n    }\r\n    return safe12temp;\r\n}\r\n```\r\n\r\nLet's take `File.createTempFile` as a source of taint, and `_.mkdir()` is a guard.\r\n```ql\r\n/**\r\n * All methods on the class `java.io.File` that create directories.\r\n */\r\nclass MethodFileCreatesDirs extends Method {\r\n  MethodFileCreatesDirs() {\r\n    getDeclaringType() instanceof TypeFile and\r\n    hasName([\"mkdir\", \"mkdirs\"])\r\n  }\r\n}\r\n\r\n/**\r\n * An expression that will create a directory without throwing an exception if a file/directory already exists.\r\n */\r\nprivate predicate isNonThrowingDirectoryCreationExpression(Expr expr, MethodAccess creationCall) {\r\n  creationCall.getMethod() instanceof MethodFileCreatesDirs and creationCall.getQualifier() = expr\r\n}\r\n\r\nprivate class DirectoryCreationBarrierGuard extends DataFlow::BarrierGuard {\r\n  DirectoryCreationBarrierGuard() { isNonThrowingDirectoryCreationExpression(_, this) }\r\n\r\n  override predicate checks(Expr e, boolean branch) {\r\n    this.controls(e, branch)\r\n  }\r\n}\r\n```\r\n\r\nRunning a query for `DirectoryCreationBarrierGuard` will find the `safe12temp.mkdir()` and `temp.mkdir()`.\r\nHowever, when quick evaluating the `DirectoryCreationBarrierGuard::checks` method, it will not find that `safe12temp.mkdir()` is a check for ` return safe12temp` and `temp.mkdir()` is a check for `return safe12temp;`.\r\n\r\nInteresting note: as soon as the outer `null` check is removed, codeQL does correctly identify the guard controls the return. For example, this is detected as correctly guarded:\r\n```java\r\nFile safe12temp;\r\nFile safe12() throws IOException {\r\n\twhile (true) {\r\n        safe12temp = File.createTempFile(\"test\", \"directory\");\r\n        if (safe12temp.delete() \u0026\u0026 safe12temp.mkdir()) {\r\n            break;\r\n        }\r\n    }\r\n    return safe12temp;\r\n}\r\n```\r\n\r\nPractical example:\r\n\r\nhttps://github.com/apache/hive/blob/cba74fa91d4035aee2c39dcf929a0ae480609540/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/HiveKVResultCache.java#L89-L103\r\n\r\nThe above code is flagged as a false positive result when executing this new query: #4473","author":{"url":"https://github.com/JLLeitschuh","@type":"Person","name":"JLLeitschuh"},"datePublished":"2022-03-18T17:23:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/8490/codeql/issues/8490"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:a90ef68a-3e5d-4828-1a08-13801ceefc84
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9BDE:3985C:D2A3B0:11D10C8:6A4D5AF1
html-safe-nonce1904ee3040b4d81f3a7b993e36d7c30a6dfd99c50a5a6cc57d1c3f75413a3fd1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkRFOjM5ODVDOkQyQTNCMDoxMUQxMEM4OjZBNEQ1QUYxIiwidmlzaXRvcl9pZCI6Ijk1MTg2NzU5MzI3Mzk4OTg3MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac0f41e3f1b644f12890d9604f84ffb55669d0844fc24327470609f749818dd95f
hovercard-subject-tagissue:1173833760
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/github/codeql/8490/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b3c5b66da618155a3f241e60374dc3cb01abbebf81d594ef8b84fd02f665c08c/github/codeql/issues/8490
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b3c5b66da618155a3f241e60374dc3cb01abbebf81d594ef8b84fd02f665c08c/github/codeql/issues/8490
og:image:altTake the following two examples: static File safe11() throws IOException { File temp = null; if (temp == null) { while (true) { temp = File.createTempFile("test", "directory"); if (temp.delete() &&...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJLLeitschuh
hostnamegithub.com
expected-hostnamegithub.com
None2a1443ff9733a3016431263ea73c93d8fe00c195eb4a7670ac30e7848f045441
turbo-cache-controlno-preview
go-importgithub.com/github/codeql git https://github.com/github/codeql.git
octolytics-dimension-user_id9919
octolytics-dimension-user_logingithub
octolytics-dimension-repository_id143040428
octolytics-dimension-repository_nwogithub/codeql
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id143040428
octolytics-dimension-repository_network_root_nwogithub/codeql
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
releasef3bdd3157ea1f0fd738d408eceeead721acf1dc3
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/github/codeql/issues/8490#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgithub%2Fcodeql%2Fissues%2F8490
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%2Fgithub%2Fcodeql%2Fissues%2F8490
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=github%2Fcodeql
Reloadhttps://github.com/github/codeql/issues/8490
Reloadhttps://github.com/github/codeql/issues/8490
Reloadhttps://github.com/github/codeql/issues/8490
Please reload this pagehttps://github.com/github/codeql/issues/8490
github https://github.com/github
codeqlhttps://github.com/github/codeql
Notifications https://github.com/login?return_to=%2Fgithub%2Fcodeql
Fork 2k https://github.com/login?return_to=%2Fgithub%2Fcodeql
Star 9.8k https://github.com/login?return_to=%2Fgithub%2Fcodeql
Code https://github.com/github/codeql
Issues 988 https://github.com/github/codeql/issues
Pull requests 424 https://github.com/github/codeql/pulls
Discussions https://github.com/github/codeql/discussions
Actions https://github.com/github/codeql/actions
Projects https://github.com/github/codeql/projects
Models https://github.com/github/codeql/models
Security and quality 0 https://github.com/github/codeql/security
Insights https://github.com/github/codeql/pulse
Code https://github.com/github/codeql
Issues https://github.com/github/codeql/issues
Pull requests https://github.com/github/codeql/pulls
Discussions https://github.com/github/codeql/discussions
Actions https://github.com/github/codeql/actions
Projects https://github.com/github/codeql/projects
Models https://github.com/github/codeql/models
Security and quality https://github.com/github/codeql/security
Insights https://github.com/github/codeql/pulse
False Negative: Guards in while loop with break fail to 'control' variable usage outsidehttps://github.com/github/codeql/issues/8490#top
Javahttps://github.com/github/codeql/issues?q=state%3Aopen%20label%3A%22Java%22
false-positivehttps://github.com/github/codeql/issues?q=state%3Aopen%20label%3A%22false-positive%22
https://github.com/JLLeitschuh
JLLeitschuhhttps://github.com/JLLeitschuh
on Mar 18, 2022https://github.com/github/codeql/issues/8490#issue-1173833760
https://github.com/apache/hive/blob/cba74fa91d4035aee2c39dcf929a0ae480609540/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/HiveKVResultCache.java#L89-L103https://github.com/apache/hive/blob/cba74fa91d4035aee2c39dcf929a0ae480609540/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/HiveKVResultCache.java#L89-L103
#4473https://github.com/github/codeql/pull/4473
Javahttps://github.com/github/codeql/issues?q=state%3Aopen%20label%3A%22Java%22
false-positivehttps://github.com/github/codeql/issues?q=state%3Aopen%20label%3A%22false-positive%22
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.