Skip to content

Commit 29a487c

Browse files
authored
chore(docs): update documentation to include SELECT keyword (#138)
* update documentation to include SELECT keyword * update docs 📖 * update readme
1 parent 6f847c7 commit 29a487c

File tree

8 files changed

+79
-14
lines changed

8 files changed

+79
-14
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ $ gradle buildGo (or) npm install -g codepathfinder
5858
$ ./pathfinder query --project <path_to_project> --stdin
5959
2024/06/30 21:35:29 Graph built successfully
6060
Path-Finder Query Console:
61-
>FROM method_declaration AS md WHERE md.getName() == "getPaneChanges"
61+
>FROM method_declaration AS md
62+
WHERE md.getName() == "getPaneChanges"
63+
SELECT md, "query for pane changes layout methods"
6264
Executing query: FROM method_declaration AS md WHERE md.getName() == "getPaneChanges"
6365

6466
┌───┬──────────────────────────────────────────┬─────────────┬────────────────────┬────────────────┬──────────────────────────────────────────────────────────────┐

docs/src/content/docs/api/Entities/index.mdx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ import PostHogLayout from '../../../../layouts/PostHogLayout.astro';
1313
The query structure is simple, easy to use and inspired by SQL. Query often start with the keyword `FIND` followed by the entity type and then the condition.
1414

1515
```sql
16-
FROM entity_type AS entity_variable WHERE condition
16+
FROM entity_type AS entity_variable
17+
WHERE condition
18+
SELECT entity_variable, "Description"
1719
```
1820

1921
## Example
2022

2123
```sql
22-
FROM method_declaration AS md WHERE "@Deprecated" in md.getAnnotation()
24+
FROM method_declaration AS md
25+
WHERE "@Deprecated" in md.getAnnotation()
26+
SELECT md, "Listing all deprecated methods"
2327
```
2428

2529
### Alias syntax
@@ -28,7 +32,9 @@ The alias syntax is used to give a name to the entity. This is useful when the e
2832
to use the alias to invoke the entity methods.
2933

3034
```sql
31-
FROM method_declaration AS md WHERE md.<Entity method>
35+
FROM method_declaration AS md
36+
WHERE md.<Entity method>
37+
SELECT md.<Entity Data>, "Example description"
3238
```
3339

3440
Learn more about the entity methods below in the API Index.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Predicates
3+
description: "Predicates - Code PathFinder API Index"
4+
---
5+
6+
import { Badge } from '@astrojs/starlight/components';
7+
import PostHogLayout from '../../../../layouts/PostHogLayout.astro';
8+
9+
<PostHogLayout>
10+
</PostHogLayout>
11+
12+
## Predicates <Badge text="new" variant="tip" size="small" />
13+
14+
Predicates are re-usable functions that can be used in the query. They are defined in the query and can be used in the query.
15+
16+
```sql
17+
predicate isPublicOrProtected(method_declaration md) {
18+
md.getVisibility() == "public" || md.getVisibility() == "protected"
19+
}
20+
21+
FROM method_declaration AS md
22+
WHERE isPublicOrProtected(md)
23+
SELECT md, "Listing all public or protected methods"
24+
```
25+
26+
27+

docs/src/content/docs/api/index.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ import PostHogLayout from '../../../layouts/PostHogLayout.astro';
99
</PostHogLayout>
1010

1111
- [Entities](./entities/)
12-
- [Conditions](./conditions/)
12+
- [Conditions](./conditions/)
13+
- [Predicates](./predicates/)

docs/src/content/docs/changelog.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ import PostHogLayout from '../../layouts/PostHogLayout.astro';
88
<PostHogLayout>
99
</PostHogLayout>
1010

11+
## v0.0.26
12+
13+
- You can now query multiple entities in a single query and compare with them in conditions and filter them like CodeQL 🚀
14+
Example:
15+
```sql
16+
FIND method_declaration AS md, method_invocation AS mi
17+
WHERE md.getName() == mi.getName() &&
18+
md.getVisibility() != "private"
19+
```
20+
- The pathfinder cli now fresh look with code, line number, file name formatted
21+
- If you make any mistakes in query, pathfinder cli advises you error message exactly line number and doesn't crash the program
22+
- Posthog had issues in previous release due to breaking changes in golang sdk from posthog, which is now fixed.
23+
1124
## v0.0.23
1225

1326
### **New Feature**:

docs/src/content/docs/index.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ import PostHogLayout from '../../layouts/PostHogLayout.astro';
2525

2626
```shell
2727
Code-PathFinder Console:
28-
> FROM method_declaration AS md WHERE md.getVisibility() == "public" && md.getName() == "main"
28+
> FROM method_declaration AS md
29+
WHERE md.getVisibility() == "public" && md.getName() == "main"
30+
SELECT md, "Listing all main methods"
2931

3032
public static void main(String[] args) {
3133
System.out.println("\"Set thy heart upon thy work, but never on its reward.\" - Bhagavad Gita, Chapter 2, Verse 47");
@@ -39,7 +41,7 @@ public static void main(String[] args) {
3941
Strengthen your code’s integrity with robust security checks and insights.
4042
</Card>
4143
<Card title="Structural Search" icon="seti:code-search">
42-
Search and identify specific patterns in your Java code seamlessly.
44+
Search and identify specific patterns in source code seamlessly.
4345
</Card>
4446
<Card title="Call Graph Analysis" icon="seti:pipeline">
4547
Visualize and analyze method calls and data flow for better understanding.

docs/src/content/docs/queries/Android/android-webview-settings.mdx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ result in cross-site scripting attacks.
2828
* @tags security
2929
* external/cwe/cwe-079
3030
*/
31-
FROM method_invocation AS mi WHERE mi.getName() == "setJavaScriptEnabled" && "true" in mi.getArgumentName()
31+
FROM method_invocation AS mi
32+
WHERE mi.getName() == "setJavaScriptEnabled" && "true" in mi.getArgumentName()
33+
SELECT mi, "Enabling JavaScript execution in a WebView can result in cross-site scripting attacks."
3234
```
3335

3436
### setAllowUniversalAccessFromFileURLs Webview API
@@ -45,7 +47,9 @@ FROM method_invocation AS mi WHERE mi.getName() == "setJavaScriptEnabled" && "tr
4547
* @tags security
4648
* external/cwe/cwe-079
4749
*/
48-
FROM method_invocation AS mi WHERE mi.getName() == "setAllowUniversalAccessFromFileURLs" && "true" in mi.getArgumentName()
50+
FROM method_invocation AS mi
51+
WHERE mi.getName() == "setAllowUniversalAccessFromFileURLs" && "true" in mi.getArgumentName()
52+
SELECT mi, "Enabling SetAllowUniversalAccessFromFileURLs leak s&&box access to file:/// URLs from any origin."
4953
```
5054

5155
### setAllowFileAccessFromFileURLs Webview API
@@ -62,7 +66,9 @@ FROM method_invocation AS mi WHERE mi.getName() == "setAllowUniversalAccessFromF
6266
* @tags security
6367
* external/cwe/cwe-079
6468
*/
65-
FROM method_invocation AS mi WHERE mi.getName() == "setAllowFileAccessFromFileURLs" && "true" in mi.getArgumentName()
69+
FROM method_invocation AS mi
70+
WHERE mi.getName() == "setAllowFileAccessFromFileURLs" && "true" in mi.getArgumentName()
71+
SELECT mi, "Enabling setAllowFileAccessFromFileURLs leak s&&box access to file:/// URLs."
6672
```
6773

6874
### setAllowContentAccess Webview API
@@ -79,7 +85,9 @@ FROM method_invocation AS mi WHERE mi.getName() == "setAllowFileAccessFromFileUR
7985
* @tags security
8086
* external/cwe/cwe-079
8187
*/
82-
FROM method_invocation WHERE mi.getName() == "setAllowContentAccess" && "true" in mi.getArgumentName()
88+
FROM method_invocation AS mi
89+
WHERE mi.getName() == "setAllowContentAccess" && "true" in mi.getArgumentName()
90+
SELECT mi, "Enabling setAllowContentAccess enables content:// access from webpages."
8391
```
8492

8593
### setAllowFileAccess Webview API
@@ -96,7 +104,9 @@ FROM method_invocation WHERE mi.getName() == "setAllowContentAccess" && "true" i
96104
* @tags security
97105
* external/cwe/cwe-079
98106
*/
99-
FROM method_invocation AS mi WHERE mi.getName() == "setAllowFileAccess" && "true" in mi.getArgumentName()
107+
FROM method_invocation AS mi
108+
WHERE mi.getName() == "setAllowFileAccess" && "true" in mi.getArgumentName()
109+
SELECT mi, "Enabling setAllowFileAccess enables webview access to file:/// URLs."
100110
```
101111

102112
### addJavascriptInterface Webview API
@@ -113,5 +123,7 @@ FROM method_invocation AS mi WHERE mi.getName() == "setAllowFileAccess" && "true
113123
* @tags security
114124
* external/cwe/cwe-079
115125
*/
116-
FROM method_invocation AS mi WHERE mi.getName() == "addJavascriptInterface"
126+
FROM method_invocation AS mi
127+
WHERE mi.getName() == "addJavascriptInterface"
128+
SELECT mi, "Enabling addJavascriptInterface exposes java methods to JavaScript."
117129
```

docs/src/content/docs/queries/Javadoc/deprecated-access.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ Pathfinder supports querying for deprecated callable access in the source code.
1717
The query syntax is simple, easy to use and inspired by SQL.
1818

1919
```sql
20-
FROM method_declaration AS md WHERE "@Deprecated" in md.getAnnotation()
20+
FROM method_declaration AS md
21+
WHERE "@Deprecated" in md.getAnnotation()
22+
SELECT md, "Listing all deprecated methods"
2123
```

0 commit comments

Comments
 (0)