Skip to content

Commit d10137f

Browse files
committed
📝 Update the README of the Transformers package to include an explanation
1 parent 713deb6 commit d10137f

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

‎static/package_page.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ function load_readme(version, scroll_to_div=false){
3232
});
3333
}
3434

35+
function put_readme(version, markupContent, scroll_to_div=false){
36+
addDynamicClickDelegation(`${version}`);
37+
38+
const contentDivs = document.querySelectorAll('.versions div');
39+
contentDivs.forEach(div => div.classList.remove('selected'));
40+
41+
document.getElementById(version).classList.add('selected');
42+
document.getElementById('markdown-container').innerHTML = marked.parse(markupContent);
43+
if (scroll_to_div) {
44+
// document.getElementById('description_pkg').scrollIntoView();
45+
history.replaceState(null, null, '#'+version);
46+
}
47+
}
48+
3549
function warn_unsafe() {
3650
document.getElementById('installdanger').hidden = false;
3751
document.getElementById('installcmd').hidden = true;

‎transformers/index.html

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,12 @@ <h6 class="text-header">
9898
</div>
9999

100100
<script>
101-
var url_readme_main = 'https://raw.githubusercontent.com/huggingface/transformers/main/README.md';
102-
103101
$(document).ready(function () {
104102
var this_vers = document.getElementById('latest-main-version').textContent.trim();
105103
document.getElementById(this_vers).classList.add('main');
106104
check_supply_chain_attack("transformers", this_vers, warn_unsafe);
107-
108-
if (window.location.hash != "") {
109-
let version_hash = window.location.hash;
110-
version = version_hash.replace('#', '');
111-
load_readme(version, scroll_to_div=true);
112-
return;
113-
}
114-
load_readme(this_vers);
105+
106+
put_readme(this_vers, "This is a (safe) example of a package vulnerable to supply chain attacks. Here we registered a private package called `transformers`. But another package with the exact same name and a higher version is registered in the public PyPi index. Running the install command would install the package registered there (which might be malicious), not my private package as intended. If that's the case, a warning is displayed in this page.");
115107
});
116108
</script>
117109
</body>

0 commit comments

Comments
 (0)