Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

16
LINES

< > BotCompany Repo | #1018160 // getCodeFragmentSafety - "S1" safety checker (simply identifier based, fixed allowed list)

JavaX fragment (include)

static Collection<S> getCodeFragmentSafety(S code) {
  SS map = codeAnalysis_identifierSafetyMap();
  Set<S> identifiers = tok_allIdentifiers(code);
  
  Collection<S> tags = treeSet();
  for (S id : identifiers) {
    S tag;
    if (codeAnalysis_isSafeIdentifier(id)) tag = "safe"; // dangerous functions don't start with $
    else tag = or2(map.get(id), "?");
    tags.addAll(tokSplitAtComma(tag));
  }
  
  tags = simplifySafetyTags(tags);
  if (empty(tags)) tags.add("safe");
  ret tags;
}

Author comment

Began life as a copy of #1015762

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1018160
Snippet name: getCodeFragmentSafety - "S1" safety checker (simply identifier based, fixed allowed list)
Eternal ID of this version: #1018160/13
Text MD5: 369986d2a8b1c23f997d51a7d047665a
Author: stefan
Category: javax / code analysis
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-15 22:09:14
Source code size: 509 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 322 / 402
Version history: 12 change(s)
Referenced in: [show references]