跳至內容
Astera Technology

伺服器專用設定,要查有沒有進客戶端

用無害假設標記核真正生成位元組。

下載完整個案資料及參考答案 ↓

訂判斷及所需輸入

SYNTHETIC_ONLY 只是測試標記,不是憑證。本例只容伺服器使用;錯生成器把它直接寫進客戶端源碼,畫面仍 Demo。更正省略該客戶端設定,Demo 照留。

已填本地測試工作表
情況輸入 JSON
原例測試{"syntheticToken":"SYNTHETIC_ONLY","serverOnly":true}
下載可編輯 CSV ↓

跑所附比較

固定生成源碼真正本地執行,再核位元組。藏畫面欄不會移除已內嵌字面值;沒有真憑證或供應商設定。

錯誤及所需輸出
路徑輸出 JSON
錯誤路徑{"clientContainsToken":true,"publicLabel":"Demo"}
所需路徑{"clientContainsToken":false,"publicLabel":"Demo"}
下載可編輯 CSV ↓
完整本地 Node24.14.1 程序
import assert from 'node:assert/strict';

const run=function run(i,corrected=true){
    if(typeof i.syntheticToken!=='string'||!i.syntheticToken||typeof i.serverOnly!=='boolean')return {held:true};
    const clientConfig=corrected&&i.serverOnly?{}:{token:i.syntheticToken};
    const clientSource='return '+JSON.stringify({label:'Demo',config:clientConfig})+';';
    const rendered=Function(clientSource)();
    return {clientContainsToken:Buffer.from(clientSource).includes(Buffer.from(i.syntheticToken)),publicLabel:rendered.label};
  };
const cases=[{"input":{"syntheticToken":"SYNTHETIC_ONLY","serverOnly":true},"corrected":false,"expected":{"clientContainsToken":true,"publicLabel":"Demo"}},{"input":{"syntheticToken":"SYNTHETIC_ONLY","serverOnly":true},"corrected":true,"expected":{"clientContainsToken":false,"publicLabel":"Demo"}},{"input":{"syntheticToken":"PUBLIC_LABEL","serverOnly":false},"corrected":true,"expected":{"clientContainsToken":true,"publicLabel":"Demo"}},{"input":{"syntheticToken":null,"serverOnly":true},"corrected":true,"expected":{"held":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
下載可執行例子 ↓

按邊界依據作判斷

明訂公開標記可出現;標記欠缺便停,空字串配對不能確立有意思的排除。

  1. 核設定可到哪一層
  2. 生成客戶端內容
  3. 核位元組及公開結果

只用無害標記,不貼真實憑證。

可編輯邊界輸入及結果
條件輸入 JSON預期輸出 JSON
設定明訂可公開{"syntheticToken":"PUBLIC_LABEL","serverOnly":false}{"clientContainsToken":true,"publicLabel":"Demo"}
測試設定欠缺{"syntheticToken":null,"serverOnly":true}{"held":true}
下載可編輯 CSV ↓

原例更正後示範了甚麼?

查看參考答案

這些客戶端位元組沒有伺服器專用標記,Demo 仍顯示;未確認所有可能帶秘密的輸出。

相關資源

雲端部署與維護 →