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)

1  
static Collection<S> getCodeFragmentSafety(S code) {
2  
  SS map = codeAnalysis_identifierSafetyMap();
3  
  Set<S> identifiers = tok_allIdentifiers(code);
4  
  
5  
  Collection<S> tags = treeSet();
6  
  for (S id : identifiers) {
7  
    S tag;
8  
    if (codeAnalysis_isSafeIdentifier(id)) tag = "safe"; // dangerous functions don't start with $
9  
    else tag = or2(map.get(id), "?");
10  
    tags.addAll(tokSplitAtComma(tag));
11  
  }
12  
  
13  
  tags = simplifySafetyTags(tags);
14  
  if (empty(tags)) tags.add("safe");
15  
  ret tags;
16  
}

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: 397 / 477
Version history: 12 change(s)
Referenced in: [show references]