Skip to contentSkip to conversation

classes: Only allow network in existing network accessing code

PATCH New Richard Purdie 1 participant 1 message Jan 7, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 classes: Only allow network in existing network accessing code

Use the newly added network task flag against tasks where network access is expected. This is do_fetch, do_checkuri, do_testimage, do_testsdk and do_testsdkext.

We can't disable networking in sstate tasks due to sstate downloads and also so we can report hash equivalence to the server so network access is enabled in sstate tasks.

Access within build-appliance do_image is also allowed due to the use of pip, this is a poor example made rather obvious now and needs to be reworked.

Network access anywhere else in any other task isn't allowed.

---
 meta/classes/base.bbclass                                | 1 +
 meta/classes/sstate.bbclass                              | 2 ++
 meta/classes/testimage.bbclass                           | 1 +
 meta/classes/testsdk.bbclass                             | 2 ++
 meta/classes/utility-tasks.bbclass                       | 1 +
 meta/recipes-core/images/build-appliance-image_15.0.0.bb | 2 ++
 6 files changed, 9 insertions(+)
meta/classes/base.bbclass +1 -0
index b709777f243..5f4956a1d31 100644
@@ -150,6 +150,7 @@ do_fetch[dirs] = "${DL_DIR}"
 do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}"
 do_fetch[file-checksums] += " ${@get_lic_checksum_file_list(d)}"
 do_fetch[vardeps] += "SRCREV"
+do_fetch[network] = "1"
 python base_do_fetch() {
 
     src_uri = (d.getVar('SRC_URI') or "").split()
meta/classes/sstate.bbclass +2 -0
index 0326d27c743..645377fdd8f 100644
@@ -158,6 +158,8 @@ python () {
     for task in unique_tasks:
         d.prependVarFlag(task, 'prefuncs', "sstate_task_prefunc ")
         d.appendVarFlag(task, 'postfuncs', " sstate_task_postfunc")
+        d.setVarFlag(task, 'network', '1')
+        d.setVarFlag(task + "_setscene", 'network', '1')
 }
 
 def sstate_init(task, d):
meta/classes/testimage.bbclass +1 -0
index 1c5fd4ee6a4..898248992c8 100644
@@ -139,6 +139,7 @@ python do_testimage() {
 
 addtask testimage
 do_testimage[nostamp] = "1"
+do_testimage[network] = "1"
 do_testimage[depends] += "${TESTIMAGEDEPENDS}"
 do_testimage[lockfiles] += "${TESTIMAGELOCK}"
 
meta/classes/testsdk.bbclass +2 -0
index 758a23ac553..8b2e74f6069 100644
@@ -36,12 +36,14 @@ python do_testsdk() {
 }
 addtask testsdk
 do_testsdk[nostamp] = "1"
+do_testsdk[network] = "1"
 
 python do_testsdkext() {
     import_and_run('TESTSDKEXT_CLASS_NAME', d)
 }
 addtask testsdkext
 do_testsdkext[nostamp] = "1"
+do_testsdkext[network] = "1"
 
 python () {
     if oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False"):
meta/classes/utility-tasks.bbclass +1 -0
index 34d6b8f4d52..0466325c131 100644
@@ -38,6 +38,7 @@ python do_clean() {
 
 addtask checkuri
 do_checkuri[nostamp] = "1"
+do_checkuri[network] = "1"
 python do_checkuri() {
     src_uri = (d.getVar('SRC_URI') or "").split()
     if len(src_uri) == 0:
meta/recipes-core/images/build-appliance-image_15.0.0.bb +2 -0
index ce72a944e74..b774095b971 100644
@@ -109,6 +109,8 @@ fakeroot do_populate_poky_src () {
 }
 
 IMAGE_PREPROCESS_COMMAND += "do_populate_poky_src; "
+# For pip usage above
+do_image[network] = "1"
 
 addtask rootfs after do_unpack
 
Signature · 1 line
2.32.0