Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ›‚ Server protects yaml as well as yml

Alicia Sykesf34b7fb650e1
diff --git a/services/app.js b/services/app.js
index a87ed19c..1c8759fa 100644
--- a/services/app.js
+++ b/services/app.js
@@ -280,9 +280,9 @@ const app = express()
safeEnd(res, errBody(e));
}
}))
- // Middleware to serve any .yml files in USER_DATA_DIR with optional protection
+ // Middleware to serve any .yml/.yaml files in USER_DATA_DIR with optional protection
// Note: returns stripped version if auth configured but not yet authenticated
- .get('/*.yml', bootstrapAuth, (req, res) => {
+ .get(/\.ya?ml$/i, bootstrapAuth, (req, res) => {
const ymlFile = req.path.split('/').pop();
const filePath = path.resolve(rootDir, process.env.USER_DATA_DIR || 'user-data', ymlFile);
if (authIsConfigured) {
diff --git a/tests/server/conf-strip.test.js b/tests/server/conf-strip.test.js
index c2d55a33..b5b85edd 100644
--- a/tests/server/conf-strip.test.js
+++ b/tests/server/conf-strip.test.js
@@ -32,6 +32,7 @@ beforeAll(() => {
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'dashy-strip-test-'));
fs.writeFileSync(path.join(tmpDir, 'conf.yml'), FULL_CONF);
fs.writeFileSync(path.join(tmpDir, 'sub.yml'), 'pageInfo:\n title: Sub\n');
+ fs.writeFileSync(path.join(tmpDir, 'sub.yaml'), 'pageInfo:\n title: Sub\n');
process.env.USER_DATA_DIR = tmpDir;
delete require.cache[require.resolve('../../services/app')];
delete require.cache[require.resolve('../../services/auth-oidc')];
@@ -72,6 +73,11 @@ describe('OIDC strip behaviour for /conf.yml', () => {
expect(res.status).toBe(401);
});
+ it('requires valid auth for non-root yaml files (not bypassed via static)', async () => {
+ const res = await request(app).get('/sub.yaml');
+ expect(res.status).toBe(401);
+ });
+
it('falls through to bootstrap on conf.yml when Bearer fails to verify', async () => {
const res = await request(app)
.get('/conf.yml')