Skip to content

📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Improvments

Smaug6739c941f2ed59dc
diff --git a/cdn/main.go b/cdn/main.go
index 50c19d47..98024a15 100644
--- a/cdn/main.go
+++ b/cdn/main.go
@@ -19,11 +19,11 @@ func main() {
r := mux.NewRouter()
fileHandler := http.FileServer(http.Dir("../uploads"))
- r.PathPrefix("/").Handler(http.StripPrefix("/", neuter(fileHandler)))
+ r.PathPrefix("/").Handler(http.StripPrefix("/", secureFileServer(fileHandler)))
// Middlewares pour la sécurité
r.Use(handlers.CompressHandler)
- r.Use(handlers.CORS())
+ r.Use(handlers.CORS(handlers.AllowedOrigins([]string{os.Getenv("DOMAIN_CLIENT")}))) // Restriction de CORS
r.Use(securityHeadersMiddleware)
fmt.Println("Server is running on port", port)
@@ -32,23 +32,30 @@ func main() {
func securityHeadersMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- //w.Header().Set("Content-Security-Policy", "default-src 'self'")
+ w.Header().Set("Content-Security-Policy", "default-src 'self'; script-src 'none'; style-src 'none'")
w.Header().Set("X-Content-Type-Options", "nosniff")
w.Header().Set("X-Frame-Options", "DENY")
- // If url starts with /other or /backups, add 'Content-Disposition', `attachment; filename` header
+ w.Header().Set("X-XSS-Protection", "1; mode=block")
+ w.Header().Set("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
+
if strings.HasPrefix(r.URL.Path, "/other") || strings.HasPrefix(r.URL.Path, "/backups") {
w.Header().Set("Content-Disposition", "attachment; filename")
}
next.ServeHTTP(w, r)
})
}
-func neuter(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if strings.HasSuffix(r.URL.Path, "/") {
- http.NotFound(w, r)
- return
- }
+func secureFileServer(next http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ // Validation du chemin pour prévenir la traversée de répertoires
+ cleanPath := cleanPath(r.URL.Path)
+ r.URL.Path = cleanPath
next.ServeHTTP(w, r)
})
}
+
+func cleanPath(path string) string {
+ // Nettoyage basique du chemin pour éviter la traversée de répertoires
+ cleanPath := strings.Replace(path, "..", "", -1)
+ return cleanPath
+}
diff --git a/frontend/styles/code.scss b/frontend/styles/code.scss
index 8604d72d..09783f51 100644
--- a/frontend/styles/code.scss
+++ b/frontend/styles/code.scss
@@ -1,5 +1,3 @@
-@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap');
-
pre code.hljs {
display: block;
overflow-x: auto;
diff --git a/frontend/styles/font.scss b/frontend/styles/font.scss
index 9fd3f1d4..12be856f 100644
--- a/frontend/styles/font.scss
+++ b/frontend/styles/font.scss
@@ -47,6 +47,7 @@
src: url(https://fonts.gstatic.com/s/inter/v13/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7SUc.woff2) format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
+
/* cyrillic */
@font-face {
font-family: 'Inter';
@@ -56,6 +57,7 @@
src: url(https://fonts.gstatic.com/s/inter/v13/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7SUc.woff2) format('woff2');
unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
+
/* greek-ext */
@font-face {
font-family: 'Inter';
@@ -65,6 +67,7 @@
src: url(https://fonts.gstatic.com/s/inter/v13/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7SUc.woff2) format('woff2');
unicode-range: U+1F00-1FFF;
}
+
/* greek */
@font-face {
font-family: 'Inter';
@@ -74,6 +77,7 @@
src: url(https://fonts.gstatic.com/s/inter/v13/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7SUc.woff2) format('woff2');
unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
+
/* vietnamese */
@font-face {
font-family: 'Inter';
@@ -83,6 +87,7 @@
src: url(https://fonts.gstatic.com/s/inter/v13/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7SUc.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
+
/* latin-ext */
@font-face {
font-family: 'Inter';
@@ -92,6 +97,7 @@
src: url(https://fonts.gstatic.com/s/inter/v13/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7SUc.woff2) format('woff2');
unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
+
/* latin */
@font-face {
font-family: 'Inter';
@@ -100,4 +106,65 @@
font-display: swap;
src: url(https://fonts.gstatic.com/s/inter/v13/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+
+/* JETBRAINS MONO */
+
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400;
+ font-display: swap;
+ src: url(https://fonts.gstatic.com/s/jetbrainsmono/v18/tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxTN1OVgaY.woff2) format('woff2');
+ unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
+}
+
+/* cyrillic */
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400;
+ font-display: swap;
+ src: url(https://fonts.gstatic.com/s/jetbrainsmono/v18/tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxTPlOVgaY.woff2) format('woff2');
+ unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
+}
+
+/* greek */
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400;
+ font-display: swap;
+ src: url(https://fonts.gstatic.com/s/jetbrainsmono/v18/tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxTOVOVgaY.woff2) format('woff2');
+ unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
+}
+
+/* vietnamese */
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400;
+ font-display: swap;
+ src: url(https://fonts.gstatic.com/s/jetbrainsmono/v18/tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxTNVOVgaY.woff2) format('woff2');
+ unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
+}
+
+/* latin-ext */
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400;
+ font-display: swap;
+ src: url(https://fonts.gstatic.com/s/jetbrainsmono/v18/tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxTNFOVgaY.woff2) format('woff2');
+ unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
+}
+
+/* latin */
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400;
+ font-display: swap;
+ src: url(https://fonts.gstatic.com/s/jetbrainsmono/v18/tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxTOlOV.woff2) format('woff2');
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
\ No newline at end of file