From 455c7a1224a2d87ca0b6285f8581bb55d6a794e1 Mon Sep 17 00:00:00 2001 From: IT23657496NethmikaKeku Date: Wed, 24 Jun 2026 11:29:39 +0530 Subject: [PATCH 1/5] feat: Added script to get the vendor using beutifulsoup4 --- README.md | 5 +- data/mins_depts_test_scored.csv | 100 ++++---- src/websitescorecard/checks/__init__.py | 2 + src/websitescorecard/checks/footer_vendor.py | 237 +++++++++++++++++++ 4 files changed, 293 insertions(+), 51 deletions(-) create mode 100644 src/websitescorecard/checks/footer_vendor.py diff --git a/README.md b/README.md index 01ee4d5..8723c52 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,10 @@ From the project root: ```bash python3 -m venv .venv -source .venv/bin/activate # Windows: .venv\Scripts\activate +# Unix: +source .venv/bin/activate +# Windows: +.venv\Scripts\activate pip install -e . ``` diff --git a/data/mins_depts_test_scored.csv b/data/mins_depts_test_scored.csv index e959f7f..77c60f5 100644 --- a/data/mins_depts_test_scored.csv +++ b/data/mins_depts_test_scored.csv @@ -1,50 +1,50 @@ -Type,Institution Name,URL,ssl_status,ssl_error -Ministry,Ministry of Defence,defence.lk,valid, -Ministry,"Ministry of Finance, Planning and Economic Development",treasury.gov.lk,valid, -Ministry,Ministry of Digital Economy,midec.gov.lk,unreachable,"[Errno 8] nodename nor servname provided, or not known" -Ministry,"Ministry of Foreign Affairs, Foreign Employment and Tourism",mfa.gov.lk,valid, -Ministry,"Ministry of Education, Higher Education and Vocational Education",moe.gov.lk,valid, -Ministry,"Ministry of Agriculture, Livestock, Land and Irrigation",agrimin.gov.lk,valid, -Ministry,"Ministry of Transport, Highways and Urban Development",transport.gov.lk,valid, -Ministry,"Ministry of Public Administration, Provincial Councils and Local Government",pubad.gov.lk,valid, -Ministry,Ministry of Health and Mass Media,health.gov.lk,valid, -Ministry,Ministry of Justice and National Integration,moj.gov.lk,valid, -Ministry,Ministry of Public Security and Parliamentary Affairs,pubsec.gov.lk,valid, -Ministry,Ministry of Industry and Entrepreneurship Development,industry.gov.lk,valid, -Ministry,"Ministry of Trade, Commerce, Food Security and Cooperative Development",ment.gov.lk,unreachable,"[Errno 8] nodename nor servname provided, or not known" -Ministry,Ministry of Environment,env.gov.lk,valid, -Ministry,Ministry of Energy,energy.gov.lk,valid, -Ministry,"Ministry of Housing, Construction and Water Supply",housingmin.gov.lk,unreachable,"[Errno 8] nodename nor servname provided, or not known" -Ministry,Ministry of Labor,labourmin.gov.lk,valid, -Ministry,Ministry of Plantation and Community Infrastructure,plantationindustries.gov.lk,invalid,"Hostname mismatch, certificate is not valid for 'plantationindustries.gov.lk'." -Ministry,Ministry of Ports and Civil Aviation,portaviation.gov.lk,unreachable,"[Errno 8] nodename nor servname provided, or not known" -Ministry,"Ministry of Fisheries, Aquatic and Ocean Resources",fisheries.gov.lk,valid, -Ministry,Ministry of Women and Child Affairs,childwomen.gov.lk,unreachable,"[Errno 8] nodename nor servname provided, or not known" -Ministry,"Ministry of Rural Development, Social Security and Community Empowerment",socialservices.gov.lk,valid, -Ministry,"Ministry of Buddhasasana, Religious and Cultural Affairs",mbra.gov.lk,unreachable,"[Errno 8] nodename nor servname provided, or not known" -Ministry,Ministry of Youth Affairs and Sports,sportsmin.gov.lk,unreachable,"[Errno 8] nodename nor servname provided, or not known" -Ministry,Ministry of Science and Technology,most.gov.lk,valid, -Department,Department of Immigration and Emigration,immigration.gov.lk,valid, -Department,Department of Motor Traffic,dmt.gov.lk,valid, -Department,Department of Registration of Persons,drp.gov.lk,valid, -Department,Department of Registrar General,rgd.gov.lk,valid, -Department,Department of Inland Revenue,ird.gov.lk,valid, -Department,Sri Lanka Customs,customs.gov.lk,valid, -Department,Department of Pensions,pensions.gov.lk,valid, -Department,Department of Census and Statistics,statistics.gov.lk,unreachable,[Errno 54] Connection reset by peer -Department,Department of Government Information,dgi.gov.lk,valid, -Department,Department of Government Printing,documents.gov.lk,valid, -Department,Department of Excise,excise.gov.lk,valid, -Department,Department of National Budget,nationalbudget.gov.lk,unreachable,"[Errno 8] nodename nor servname provided, or not known" -Department,Department of Meteorology,meteo.gov.lk,valid, -Department,Department of Wildlife Conservation,dwc.gov.lk,unreachable,"[Errno 8] nodename nor servname provided, or not known" -Department,Department of Forest Conservation,forestdept.gov.lk,expired,unable to get local issuer certificate -Department,Department of National Zoological Gardens,colombozoo.gov.lk,unreachable,"[Errno 8] nodename nor servname provided, or not known" -Department,Department of Examinations,doenets.lk,valid, -Department,Department of Archaeology,archaeology.gov.lk,valid, -Department,Department of Samurdhi,samurdhi.gov.lk,valid, -Department,LSF,opensource.lk,invalid,"Hostname mismatch, certificate is not valid for 'opensource.lk'." -Expired,Expired SSL,expired.badssl.com,unreachable,[Errno 54] Connection reset by peer -Self-Signed,Self-Signed SSL,self-signed.badssl.com,invalid,self-signed certificate -Wrong Host,Wrong Host SSL,wrong.host.badssl.com,invalid,"Hostname mismatch, certificate is not valid for 'wrong.host.badssl.com'." -Never SSL,Never SSL,neverssl.com,valid, +Type,Institution Name,URL,ssl_status,ssl_error,footer_vendor,footer_vendor_error +Ministry,Ministry of Defence,defence.lk,valid,,unknown, +Ministry,"Ministry of Finance, Planning and Economic Development",treasury.gov.lk,valid,,unknown, +Ministry,Ministry of Digital Economy,midec.gov.lk,unreachable,[Errno 11001] getaddrinfo failed,unreachable,Failed to fetch page +Ministry,"Ministry of Foreign Affairs, Foreign Employment and Tourism",mfa.gov.lk,valid,,unknown, +Ministry,"Ministry of Education, Higher Education and Vocational Education",moe.gov.lk,valid,,unknown, +Ministry,"Ministry of Agriculture, Livestock, Land and Irrigation",agrimin.gov.lk,valid,,unknown, +Ministry,"Ministry of Transport, Highways and Urban Development",transport.gov.lk,valid,,unknown, +Ministry,"Ministry of Public Administration, Provincial Councils and Local Government",pubad.gov.lk,valid,,unknown, +Ministry,Ministry of Health and Mass Media,health.gov.lk,valid,,unknown, +Ministry,Ministry of Justice and National Integration,moj.gov.lk,valid,,unknown, +Ministry,Ministry of Public Security and Parliamentary Affairs,pubsec.gov.lk,valid,,found,Minister +Ministry,Ministry of Industry and Entrepreneurship Development,industry.gov.lk,valid,,unknown, +Ministry,"Ministry of Trade, Commerce, Food Security and Cooperative Development",ment.gov.lk,unreachable,[Errno 11001] getaddrinfo failed,unreachable,Failed to fetch page +Ministry,Ministry of Environment,env.gov.lk,valid,,unknown, +Ministry,Ministry of Energy,energy.gov.lk,valid,,unknown, +Ministry,"Ministry of Housing, Construction and Water Supply",housingmin.gov.lk,unreachable,[Errno 11001] getaddrinfo failed,unreachable,Failed to fetch page +Ministry,Ministry of Labor,labourmin.gov.lk,valid,,found,SLT DIgital. About Contact Us FAQ Term & Conditions Privacy +Ministry,Ministry of Plantation and Community Infrastructure,plantationindustries.gov.lk,invalid,"Hostname mismatch, certificate is not valid for 'plantationindustries.gov.lk'.",found,University of Kelaniya +Ministry,Ministry of Ports and Civil Aviation,portaviation.gov.lk,unreachable,[Errno 11001] getaddrinfo failed,unreachable,Failed to fetch page +Ministry,"Ministry of Fisheries, Aquatic and Ocean Resources",fisheries.gov.lk,unreachable,[WinError 10061] No connection could be made because the target machine actively refused it,unknown, +Ministry,Ministry of Women and Child Affairs,childwomen.gov.lk,unreachable,[Errno 11001] getaddrinfo failed,unreachable,Failed to fetch page +Ministry,"Ministry of Rural Development, Social Security and Community Empowerment",socialservices.gov.lk,valid,,unknown, +Ministry,"Ministry of Buddhasasana, Religious and Cultural Affairs",mbra.gov.lk,unreachable,[Errno 11001] getaddrinfo failed,unreachable,Failed to fetch page +Ministry,Ministry of Youth Affairs and Sports,sportsmin.gov.lk,unreachable,[Errno 11001] getaddrinfo failed,unreachable,Failed to fetch page +Ministry,Ministry of Science and Technology,most.gov.lk,valid,,unknown, +Department,Department of Immigration and Emigration,immigration.gov.lk,valid,,unknown, +Department,Department of Motor Traffic,dmt.gov.lk,valid,,found,Procons Infotech Last Update +Department,Department of Registration of Persons,drp.gov.lk,valid,,unknown, +Department,Department of Registrar General,rgd.gov.lk,valid,,unknown, +Department,Department of Inland Revenue,ird.gov.lk,valid,,unreachable,Failed to fetch page +Department,Sri Lanka Customs,customs.gov.lk,valid,,unknown, +Department,Department of Pensions,pensions.gov.lk,valid,,found,Procons Infotech +Department,Department of Census and Statistics,statistics.gov.lk,unreachable,[WinError 10054] An existing connection was forcibly closed by the remote host,unreachable,Failed to fetch page +Department,Department of Government Information,dgi.gov.lk,valid,,unknown, +Department,Department of Government Printing,documents.gov.lk,valid,,unknown, +Department,Department of Excise,excise.gov.lk,valid,,unknown, +Department,Department of National Budget,nationalbudget.gov.lk,unreachable,[Errno 11001] getaddrinfo failed,unreachable,Failed to fetch page +Department,Department of Meteorology,meteo.gov.lk,valid,,unknown, +Department,Department of Wildlife Conservation,dwc.gov.lk,unreachable,[Errno 11001] getaddrinfo failed,unreachable,Failed to fetch page +Department,Department of Forest Conservation,forestdept.gov.lk,expired,certificate has expired,found,Procons Infotech +Department,Department of National Zoological Gardens,colombozoo.gov.lk,unreachable,[Errno 11001] getaddrinfo failed,unreachable,Failed to fetch page +Department,Department of Examinations,doenets.lk,valid,,unknown, +Department,Department of Archaeology,archaeology.gov.lk,valid,,found,University of Kelaniya +Department,Department of Samurdhi,samurdhi.gov.lk,valid,,unknown, +Department,LSF,opensource.lk,valid,,unknown, +Expired,Expired SSL,expired.badssl.com,expired,certificate has expired,unknown, +Self-Signed,Self-Signed SSL,self-signed.badssl.com,invalid,self-signed certificate,unknown, +Wrong Host,Wrong Host SSL,wrong.host.badssl.com,invalid,"Hostname mismatch, certificate is not valid for 'wrong.host.badssl.com'.",unknown, +Never SSL,Never SSL,neverssl.com,valid,,unreachable,Failed to fetch page diff --git a/src/websitescorecard/checks/__init__.py b/src/websitescorecard/checks/__init__.py index fd94d37..37dd126 100644 --- a/src/websitescorecard/checks/__init__.py +++ b/src/websitescorecard/checks/__init__.py @@ -6,11 +6,13 @@ from websitescorecard.checks.base import Check from websitescorecard.checks.ssl import SSLCheck +from websitescorecard.checks.footer_vendor import FooterVendorCheck CheckFactory = Callable[[], Check] CHECK_REGISTRY: dict[str, CheckFactory] = { "ssl": SSLCheck, + "footer_vendor": FooterVendorCheck, } diff --git a/src/websitescorecard/checks/footer_vendor.py b/src/websitescorecard/checks/footer_vendor.py new file mode 100644 index 0000000..c40e596 --- /dev/null +++ b/src/websitescorecard/checks/footer_vendor.py @@ -0,0 +1,237 @@ +"""Footer vendor/developer credit check. + +Scrapes the footer of a webpage and attempts to identify who built it — +typically a web agency or technology vendor credited in small print. + +Extraction strategy +------------------- +1. Fetch the page over HTTPS (falls back to HTTP). +2. Parse the first ``