Skip to content

Commit 821390b

Browse files
Abhijna ParigiAbhijna Parigi
authored andcommitted
Add hybrid search and AI chat using Meilisearch and OpenAI
- Implement hybrid semantic + keyword search with Meilisearch - Add AI-powered chat responses using OpenAI GPT-3.5 - Integrate 'Ask AI' feature directly into search dropdown - Add secure Netlify functions for search and chat APIs
1 parent e9418e6 commit 821390b

File tree

134 files changed

+5689
-7855
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+5689
-7855
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ yarn-error.log*
3131

3232
# Ignore .history
3333
/.history/
34+
meili_data/

docs/cheat-sheets/django-xss.mdx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
---
22
slug: django-xss
3-
displayed_sidebar: learnSidebar
4-
title: "XSS in Django"
5-
hide_title: false
6-
description: "Cheat sheet for the prevention of Cross-site Scripting (XSS) vulnerabilities for Python and Django."
7-
tags:
8-
- python
9-
- xss
3+
description: "Django XSS mitigation cheat sheet."
104
---
115

126
import LinkToRegistryRule from "/src/components/LinkToRegistryRule"
137
import XssInjectionIntro from "/src/components/concept/_xss-injection-intro.mdx"
148
import RecommendedRuleSet from "/src/components/code_snippets/_cheat-sheets-recommended-rule-set.mdx"
159

16-
# Prevent XSS in Django
10+
# XSS prevention for Django
1711

1812
<XssInjectionIntro />
1913

20-
Learn more about [Cross-site Scripting](/docs/learn/vulnerabilities/cross-site-scripting) vulnerability concepts.
21-
2214
## Mitigation summary
2315

2416
In general, always use the template engine provided by Django using `render()`. If you need HTML escaping, use `mark_safe()` combined with `format_html() `and review each individual usage carefully. Once reviewed, mark with `# nosem`. Beware of putting data in dangerous locations in templates. And as always, run a security checker continuously on your code.

docs/cheat-sheets/express-xss.mdx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
---
22
slug: express-xss
3-
displayed_sidebar: learnSidebar
4-
title: XSS in ExpressJS
5-
hide_title: true
6-
description: "Cheat sheet for the prevention of Cross-site Scripting (XSS) vulnerabilities for ExpressJS."
7-
tags:
8-
- javascript
9-
- xss
3+
description: "ExpressJS mitigation cheat sheet by Semgrep."
104
---
115

126
import LinkToRegistryRule from "/src/components/LinkToRegistryRule"
137
import XssInjectionIntro from "/src/components/concept/_xss-injection-intro.mdx"
148
import RecommendedRuleSet from "/src/components/code_snippets/_cheat-sheets-recommended-rule-set.mdx"
159

16-
# Prevent XSS in ExpressJS
10+
# XSS prevention for ExpressJS
1711

1812
<XssInjectionIntro />
1913

20-
Learn more about [Cross-site Scripting](/docs/learn/vulnerabilities/cross-site-scripting) vulnerability concepts.
21-
2214
## Mitigation summary
2315

2416
In general, always use a template engine and `res.render()` to render HTML content. Some common template engines include Pug, Mustache, and EJS. If you need HTML escaping, escape the content. Try to do so in JavaScript code if possible. Review each individual case carefully. Once reviewed, exempt the finding with `# nosemgrep`. Beware of putting data in dangerous locations such as in `script` tags. And as always, run a security checker on your code.

docs/cheat-sheets/flask-xss.mdx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
---
22
slug: flask-xss
3-
displayed_sidebar: learnSidebar
4-
title: "XSS in Flask"
5-
hide_title: false
6-
description: "Cheat sheet for the prevention of Cross-site Scripting (XSS) vulnerabilities for Python and Flask."
7-
tags:
8-
- python
9-
- xss
3+
description: "Flask XSS prevention cheat sheet."
104
---
115

126
import LinkToRegistryRule from "/src/components/LinkToRegistryRule"
137
import XssInjectionIntro from "/src/components/concept/_xss-injection-intro.mdx"
148
import RecommendedRuleSet from "/src/components/code_snippets/_cheat-sheets-recommended-rule-set.mdx"
159

16-
# Prevent XSS for Flask
10+
# XSS prevention for Flask
1711

1812
<XssInjectionIntro />
1913

20-
Learn more about [Cross-site Scripting](/docs/learn/vulnerabilities/cross-site-scripting) vulnerability concepts.
21-
2214
## Mitigation summary
2315

2416
In general, you should use `render_template()` when showing data to users. If you need HTML escaping, use `Markup()` and review

docs/cheat-sheets/go-command-injection.mdx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
---
22
slug: go-command-injection
3-
displayed_sidebar: learnSidebar
4-
title: "Command Injection in Go"
5-
hide_title: true
6-
description: "Cheat sheet for the prevention of Command Injection vulnerabilities for Go."
7-
tags:
8-
- go
9-
- command-injection
3+
description: "Prevent command injection in Go."
104
---
115

126
import LinkToRegistryRule from "/src/components/LinkToRegistryRule"
137
import CommandInjectionIntro from "/src/components/concept/_command-injection-intro.mdx"
148
import RecommendedRuleSet from "/src/components/code_snippets/_cheat-sheets-recommended-rule-set.mdx"
159

16-
## Prevent Command Injection for Go
10+
# Command injection prevention for Go
1711

1812
<CommandInjectionIntro />
1913

20-
Learn more about [Command Injection](/docs/learn/vulnerabilities/command-injection) vulnerability concepts.
21-
22-
2314
### Check your project using Semgrep
2415

2516
<RecommendedRuleSet />

docs/cheat-sheets/go-xss.mdx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
---
22
slug: go-xss
3-
displayed_sidebar: learnSidebar
4-
title: "XSS in Go"
5-
hide_title: true
6-
description: "Cheat sheet for the prevention of Cross-site Scripting (XSS) vulnerabilities for Go and net/http."
7-
tags:
8-
- go
9-
- xss
3+
description: "XSS prevention cheat sheet for Go 'net/http'."
104
---
115

126
import LinkToRegistryRule from "/src/components/LinkToRegistryRule"
137
import XssInjectionIntro from "/src/components/concept/_xss-injection-intro.mdx"
148
import RecommendedRuleSet from "/src/components/code_snippets/_cheat-sheets-recommended-rule-set.mdx"
159

16-
## Prevent XSS for Go
10+
# XSS prevention for Go net/http
1711

1812
<XssInjectionIntro />
1913

20-
Learn more about [Cross-site Scripting](/docs/learn/vulnerabilities/cross-site-scripting) vulnerability concepts.
21-
2214
## Mitigation summary
2315

2416
The Go template engine in `html/template` does automatic and contextual autoescaping, which mitigates many common XSS mistakes. Some aspects of the engine are confusingly named; therefore, proper use of the library should be enforced using code scanners. You may also consider using a stricter alternative, such as `safehtml`.

docs/cheat-sheets/java-code-injection.mdx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
---
22
slug: java-code-injection
3-
title: Code Injection in Java
4-
hide_title: true
5-
description: "Cheat sheet for the prevention of Code Injection vulnerabilities for Java."
6-
displayed_sidebar: learnSidebar
7-
tags:
8-
- java
9-
- code-injection
3+
description: "Prevent potential code injection in Java."
4+
displayed_sidebar: cheatsheetSidebar
105
---
116

127
import LinkToRegistryRule from "/src/components/LinkToRegistryRule"
138
import CodeInjectionIntro from "/src/components/concept/_code-injection-intro.mdx"
149
import RecommendedRuleSet from "/src/components/code_snippets/_cheat-sheets-recommended-rule-set.mdx"
1510

16-
## Prevent Code Injection for Java
11+
# Code injection prevention for Java
1712

1813
<CodeInjectionIntro />
1914

20-
Learn more about [Code Injection](/docs/learn/vulnerabilities/code-injection) vulnerability concepts.
21-
2215
### Check your project using Semgrep
2316

2417
<RecommendedRuleSet />

docs/cheat-sheets/java-command-injection.mdx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
---
22
slug: java-command-injection
3-
displayed_sidebar: learnSidebar
4-
title: Command Injection in Java
5-
hide_title: true
6-
description: "Cheat sheet for the prevention of Command Injection vulnerabilities for Java."
7-
tags:
8-
- java
9-
- command-injection
3+
description: "Mitigate command injection in Java."
104
---
115

126
import LinkToRegistryRule from "/src/components/LinkToRegistryRule"
137
import CommandInjectionIntro from "/src/components/concept/_command-injection-intro.mdx"
148
import RecommendedRuleSet from "/src/components/code_snippets/_cheat-sheets-recommended-rule-set.mdx"
159

16-
# Prevent Command Injection for Java
10+
# Command injection prevention for Java
1711

1812
<CommandInjectionIntro />
1913

20-
Learn more about [Command Injection](/docs/learn/vulnerabilities/command-injection) vulnerability concepts.
21-
2214
### Check your project using Semgrep
2315

2416
<RecommendedRuleSet />

docs/cheat-sheets/java-jsp-xss.mdx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
---
22
slug: java-jsp-xss
3-
displayed_sidebar: learnSidebar
4-
title: XSS in Java + JSP
5-
hide_title: true
6-
description: "Cheat sheet for the prevention of Cross-site Scripting (XSS) vulnerabilities for Java and Java Server Pages (JSP)."
7-
tags:
8-
- java
9-
- xss
3+
description: "XSS prevention for Java + JavaServer Pages (JSP)."
104
---
115

126
import LinkToRegistryRule from "/src/components/LinkToRegistryRule"
137
import XssInjectionIntro from "/src/components/concept/_xss-injection-intro.mdx"
148
import RecommendedRuleSet from "/src/components/code_snippets/_cheat-sheets-recommended-rule-set.mdx"
159

16-
# Prevent XSS for Java and Java Server Pages (JSP)
10+
# XSS prevention for Java + JSP
1711

1812
<XssInjectionIntro />
1913

20-
Learn more about [Cross-site Scripting](/docs/learn/vulnerabilities/cross-site-scripting) vulnerability concepts.
21-
2214
## Mitigation Summary
2315

2416
JSPs are fraught with peril. HTML escaping in JSP templates requires escaping all data that is rendered onto the page. Worse, business logic can be embedded into JSPs with scriptlets. This is easy to forget or abuse and can easily create XSS vulnerabilities. The default option should be the safe option: Consider using a view or template engine that escapes by default, such as JSF or Velocity. If you cannot migrate to another framework, use a custom EL resolver that applies escaping by default in JSPs, such as

docs/cheat-sheets/java-xxe.mdx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
---
22
slug: java-xxe
3-
title: XEE in Java
4-
hide_title: true
53
toc_max_heading_level: 4
6-
displayed_sidebar: learnSidebar
7-
description: "Cheat sheet for the prevention of XML External Entity (XEE) vulnerabilities for Java."
8-
tags:
9-
- java
10-
- xxe
4+
description: "XML External entity prevention cheat sheet for Java. "
115
---
126

13-
# Prevent XML External Entity Vulnerabilities for Java
7+
# XML External entity prevention for Java
148

159
This article documents two attacks related to XML external entities: XML exponential entity expansion and XML external entity injection. In Java, applications are secure from exponential entity expansion by default. Consequently, no security measures are necessary. When exponential entity expansion occurs the JDK throws an exception, but if this exception is not caught and handled, an attack can still cause a denial-of-service attack (DoS). In contrast, there are various countermeasures to protect a Java XML parser from XML external entity injection, but not all are effective. This cheat sheet also provides test results, availability, and the effect of different security measures on several Java classes that process XML documents in section [3. Overview of the effect of security measures for each class](#3-overview-of-the-effect-of-security-measures-for-each-class).
1610

17-
Learn more about [XML Security](/docs/learn/vulnerabilities/xml-security) vulnerability concepts.
18-
1911
## Check your project using Semgrep
2012

2113
You may use [Pro rules](/semgrep-code/pro-rules/) to check your project for XXE vulnerabilities.

0 commit comments

Comments
 (0)