僕と技術とセキュリティ

セキュリティエンジニアの備忘録

Slackのリンクプレビューは

掲題の通り、自分のメモ書きとして残す。

やったこと

firebaseに対して以下の様なアプリを立てた

const functions = require('firebase-functions');
const express = require('express');

const app = express();
app.get('/redirect', (req, res) => {
  res.location('https://requestbin.fullcontact.com/******61?from=redirect')
  res.send(301, null);
})
app.get('/href', (req, res) => {
  res.setHeader('Content-type', 'text/html')
  res.write(
    `<h1>Location.href</h1>
     <script>location.href="https://requestbin.fullcontact.com/******61?from=href"</script>`
  )
  res.send(200);
})

exports.app = functions.https.onRequest(app);
  • /redirectにアクセスがあれば Location:https://requestbin.fullcontact.com/******61?from=redirectを付与してリダイレクト

  • /hrefにアクセスがあれば location.href="https://requestbin.fullcontact.com/******61?from=href"でリダイレクト

Slackにリンクを貼り付けてリンクプレビューを取得させた。

結果

Location:ヘッダの方はリダイレクトした。

f:id:halkichi-web:20190709231429p:plain
redirect